C Programming Practicals1 - Buea
C Programming Practicals1 - Buea
PRACTICAL/TUTORIAL SHEET
Write a C Program making use of strings, if statements, for loop, while loop, do while loop,
arrays, functions, pointers, files where necessary. Comment your work to make it explicit.
1. To prompt for an integer value from the keyboard and print it on the screen
2. To prompt for two decimal values from the keyboard and print the sum on the screen
3. To prompt for three integer values from the keyboard and prints the highest of the numbers on the
screen using:
a) if statement
b) case statement
4. To display the sum and the average of the first 100 integer numbers on the screen using:
a) for loop
b) while loop
c) Do while loop
5. To convert from Decimal to Binary number system
6. To get an integer number and checks if it is odd or even. If odd, add 1, if even, add 2
7. To get an integer number and check if it is prime or not
8. To get an integer number and get the first and last digit then add them
9. To get an integer number and display the factors
10. To get two integer numbers and look for the LCM and HCF
11.To count number of digits in an integer
12.To check if a number is a Strong number or not. (a Strong number is a special number
whose sum of factorial of digits is equal to the original number. For example: 145 is
strong number. Since, 1! + 4! + 5! = 145)
13.To check if a number is an Armstrong number or not. (An Armstrong number is a n-
th 1
digit number that is equal to the sum of the n power of its digits. For example 6 = 6
3 3 3
= 6 ; 371 = 3 + 7 + 1 = 371)
14. To print Fibonacci series (Fibonacci series is a series of numbers where the current
number is the sum of previous two terms. For Example: 0, 1, 1, 2, 3, 5, 8, 13, 21, ... ,
(n-1th + n-2th)
15. To check whether the number is Perfect number or not (Perfect number is a positive integer
which is equal to the sum of its proper positive divisors. For example: 6 is the first perfect number
Proper divisors of 6 are 1, 2, 3 Sum of its proper divisors = 1 + 2 + 3 = 6. Hence 6 is a perfect
number)