Expert Dot Net

Trust me to find new way !

C Programming Exercises, Practice, Solution : For Loop

1. Write a program in C to display the first 10 natural numbers. 
Expected Output :
1 2 3 4 5 6 7 8 9 10

2. Write a C program to find the sum of first 10 natural numbers. 
Expected Output : 
The first 10 natural number is :
1 2 3 4 5 6 7 8 9 10 
The Sum is : 55

3. Write a program in C to display n terms of natural number and their sum.
Test Data : 7 
Expected Output : 
The first 7 natural number is : 
1 2 3 4 5 6 7 
The Sum of Natural Number upto 7 terms : 28 

4. Write a program in C to read 10 numbers from keyboard and find their sum and average. 
Test Data :
Input the 10 numbers : 
Number-1 :2 
... 
Number-10 :2 
Expected Output : 
The sum of 10 no is : 55 
The Average is : 5.500000

5. Write a program in C to display the cube of the number upto given an integer. 
Test Data :
Input number of terms : 5 
Expected Output : 
Number is : 1 and cube of the 1 is :1 
Number is : 2 and cube of the 2 is :8 
Number is : 3 and cube of the 3 is :27 
Number is : 4 and cube of the 4 is :64 
Number is : 5 and cube of the 5 is :125

6. Write a program in C to display the multiplication table of a given integer. 
Test Data :
Input the number (Table to be calculated) : 15 
Expected Output : 
15 X 1 = 15 
...
... 
15 X 10 = 150

7. Write a program in C to display the multiplication table of a given integer. 
Test Data :
Input the number (Table to be calculated) : 15 
Expected Output : 
15 X 1 = 15 
...
... 
15 X 10 = 150

8. Write a program in C to make such a pattern like right angle triangle with a number which will repeat a number in a row. 

The pattern like :

 1
 22
 333
 4444

9. Write a program in C to display the n terms of odd natural number 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 

10. Write a program in C to display the pattern like right angle triangle using an asterisk. 

The pattern like :

*
**
***
****