Practical Work 2
Practical Work 2
1. Write a C program to display the first N odd if it equals to its divisors. for example: 6 is
perfect because 1+2+3=6.
natural numbers and their sum, S=1+3+5+…...
7. Write a C program that successively requests 20
2. Calculates and displays the sum
user's numbers, and then presents what was the
S= 22+42+62+…… by taking N term. maximum among these 20 numbers. Then
modify the program so that it also displays in
3. Reads a positive integer N and then displays its
which position this number was entered.
factorial. N! = N*(N-1) *…..*3*2*1.With 0!=1 8. Rewrite the previous program, but this time, we
4. Calculates the power XN of a real number X. do not know in advance how much numbers the
user wants to enter. The entry of numbers stops
XN = X*X*X*….*X, N times. Home work1
when the user enters a zero.
5. Write an algorithm that displays the integers 9. write a program that asks for a starting number
which are multiples of 3 and less than a number and then displays the next ten numbers for
N given by the user. example, if the user enters the number 17, the
6. write a C program that displays the divisors of program will display the numbers from 18 to
an integer N. modify this program to determine 27. Home work 2
whether a number p entered from the keyboard
is perfect. We say that a given number is perfect