0% found this document useful (0 votes)
9 views6 pages

C problems

Uploaded by

narayandas37676
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views6 pages

C problems

Uploaded by

narayandas37676
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

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 compute the sum of the 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 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

4. Write a program in C to display the multiplier table vertically from 1 to n.


Test Data :
Input upto the table number starting from 1 : 8
Expected Output :
Multiplication table from 1 to 8
1x1 = 1, 2x1 = 2, 3x1 = 3, 4x1 = 4, 5x1 = 5, 6x1 = 6, 7x1 = 7, 8x1 = 8
...
1x10 = 10, 2x10 = 20, 3x10 = 30, 4x10 = 40, 5x10 = 50, 6x10 = 60, 7x10 = 70, 8x10 = 80
5. Write a program in C to display a pattern like a right angle triangle using an asterisk.

The pattern like :

*
**
***
****

6. Write a C program to make such a pattern as a pyramid with an asterisk.

*
**
***
****

7. Write a C program to calculate the factorial of a given number.


Test Data :
Input the number : 5
Expected Output :
The Factorial of 5 is: 120

8. Write a C program to make such a pattern like a pyramid with a number which will repeat the
number in the same row.

1
22
333
4444
9. Write a program in C to find the sum of the series [ 1-X^2/2!+X^4/4!- .........].

Test Data :

Input the Value of x :2

Input the number of terms : 5

Expected Output :

the sum = -0.415873

Number of terms = 5

value of x = 2.000000

10. Write a program in C to display the n terms of a harmonic series and their sum.

1 + 1/2 + 1/3 + 1/4 + 1/5 ... 1/n terms

Test Data :

Input the number of terms : 5

Expected Output :

1/1 + 1/2 + 1/3 + 1/4 + 1/5 +

Sum of Series upto 5 terms : 2.283334

11. Write a program in C to display the sum of the series [ 9 + 99 + 999 + 9999 ...].
Test Data :
Input the number or terms :5
Expected Output :
9 99 999 9999 99999
The sum of the saries = 111105

12. Write a C program to check whether a given number is a 'Perfect' number or not.
Test Data :
Input the number : 56
Expected Output :
The positive divisor : 1 2 4 7 8 14 28
The sum of the divisor is : 64
So, the number is not perfect.

13. Write a C program to check whether a given number is an Armstrong number or not.
Test Data :
Input a number: 153
Expected Output :
153 is an Armstrong number.

14. Write a C program to determine whether a given number is prime or not.


Test Data :
Input a number: 13
Expected Output :
13 is a prime number.

15. Write a C program to display Pascal's triangle.


Test Data :
Input number of rows: 5
Expected Output :
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1

16. Write a program in C to display the first n terms of the Fibonacci series.
Fibonacci series 0 1 2 3 5 8 13 .....
Test Data :
Input number of terms to display : 10

Expected Output :
Here is the Fibonacci series upto to 10 terms :
0 1 1 2 3 5 8 13 21 34

17. Write a program in C to display a given number in reverse order.


Test Data :
Input a number: 12345
Expected Output :
The number in reverse order is : 54321

18. Write a C program to check whether a number is a palindrome or not.


Test Data :
Input a number: 121
Expected Output :
121 is a palindrome number.
19. Write a C program to find the LCM of any two numbers using HCF.
Test Data :
Input 1st number for LCM: 15
Input 2nd number for LCM: 20
Expected Output :
The LCM of 15 and 20 is : 60

20. Write a program in C to find the LCM of any two numbers.


Test Data :
Input 1st number for LCM: 15
Input 2nd number for LCM: 20
Expected Output :
The LCM of 15 and 20 is : 60

21. Write a C program to check whether a number is a Strong Number or not.


Test Data :
Input a number to check whether it is Strong number: 15
Expected Output :
15 is not a Strong number.

You might also like