Loop Assignments
Loop Assignments
Given an exam marks as input, display the appropriate message based on the
rules below:
If marks is greater than 49, display “PASS”, otherwise display “FAIL”. However, for
input outside the 0-100 range, display “WRONG INPUT” and prompt the user to input
again until a valid input is entered.
2. print the list of N natural number.
Expected Output :
1 2 3 4 5 6 7 8 9 10
3. Take an weight continiously and print it until weight is less than 65.
4. Print the sum of N natural number and sum of square of N natural number using
for and while both.
Expected Output :
The first 10 natural number is :
1 2 3 4 5 6 7 8 9 10
The Sum is : 55
5. Compute and print the GCD of two number.
6. Find the number of month to double your money and print it. If money is
increasing 2% in each month.
7. Maximum of positive number infinitely using while loop. And stop the loop using
negative number.
8. Find the sum of all digits of a number.
9. Find the factorial using loop.
10. Convert decimal to binary.
11. Check a number is prime or not and print the result.
12. Write a program in C to read 10 numbers from the keyboard and find their sum
and average.
Test Data :
Input the 10 numbers :
13. Write a program in C to display the multiplication table for a given integer.
Test Data :
Input the number (Table to be calculated) : 15
Expected Output :
15 X 1 = 15
...
...
15 X 10 = 150
14. Write a C program to display the n terms of odd natural numbers and their sum.
Test Data
Input number of terms : 10
Expected Output :
The odd numbers are :1 3 5 7 9 11 13 15 17 19
The Sum of odd Natural Number upto 10 terms : 100
15. Write a program in C to display a pattern like a right angle triangle using an
asterisk.
The pattern like :
*
**
***
****
16. Write a C program to display a pattern like a right angle triangle with a number.
The pattern like :
1
12
123
1234
17. Write a program in C to make such a pattern like a right angle triangle with a number
which will repeat a number in a row.
18. Write a program in C to make such a pattern like a right angle triangle with the number
increased by 1.
1
2 3
4 5 6
7 8 9 10
*
* *
* * *
* * * *