Topic5-Introduction To Loop and Using Loop For - ASSIGNMENT2
Topic5-Introduction To Loop and Using Loop For - ASSIGNMENT2
5. Compute and display the summation of the suit cube number starting from
1 up to n, where n is the input number entered by a user, n is greater than 1.
5. Ex: Suppose the input is 3, then display 1^3 + 2^3 + 3^3 = 36
9. Compute and display the summation of the suit cube number starting from
n up to 1, where n is the input number entered by a user, n is greater than 1.
9. Ex: Suppose the input is 3, then display 3^3 + 2^3 + 1^3 = 36
10. Check whether an input number is a primary number or not. The program
runs indefinitely so that we can always check another input number.
11. Display all primary numbers in between 2 to 500.
12. Read 20 input numbers from a user and then find the maximum number
and display it on screen.
14
Assignment (part 2)
Loop exercises: Write a C program to …
13. Check whether an input number is a perfect number or not. The program
runs indefinitely so that we can always check another input number.
Perfect number is a positive integer that is equal to the sum of its proper divisors,
excluding the number itself.
E.g: 6 is a perfect number. • 6 has divisors 1, 2 and 3
• Since
Since thethe sum
sum ofofitsitsdivisors
divisors1,
1, 2,
2, and
and 33 are
areequal
equaltoto6.6.
15
Assignment (part 2)
Loop exercises: Write a C program to …
14. Read 10 input numbers from a user and then find the minimum number and
display it on screen.
15. Display the first n numbers of suit Fibonacci, where n is a number entered
by a user.
The Fibonacci Sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...
The next number is found by adding up the two numbers before it.
16. Ask a user to input many numbers as possible. When the user inputs 0 or -1,
stop asking the user for the number and display the total summation of all
input numbers on the screen.
17