Lab Assignment 221024
Lab Assignment 221024
Lab Assignment 221024
2. Write a C program that takes a positive integer from the user and invokes a function
to compute and print the binary equivalent of the integer.
3. Write a C program that takes a positive integer from the user and invokes a function
to obtain the prime factors of this number. For example, prime factors of 24 are 2, 2, 2 and
3, whereas prime factors of 35 are 5 and 7.
3. Write a C program that invokes two functions for swapping the value of two variables.
The first function (swap_by_value) should demonstrate call by value principle while the
second function (swap_by_reference) should demonstrate call by reference principle. The
program should print the following in the given order:
5. A computer game to ascend a building with a specified number of floors. You have three
different facilities for each floor to reach the top: the elevator (1), the escalator (2), and
walking up the stairs (3).
Each facility has its own scoring rule. Assume the initial score is zero.
Example: If number of floors 4 and person chosen 3 for first floor, 2 for second floor, 3 for
third floor and 2 for fourth floor. The score is 2(first prime number) +1(first odd number)
+3(next prime number) +3(next odd number) =9.
Write a C program to display the score to ascend a building. Create different functions
for incrementing score according to the facility.