0% found this document useful (0 votes)
14 views4 pages

C Programming Exercises and Solutions

The document provides 25 coding problems in C language with examples of printing patterns, checking number properties, performing calculations, and converting between bases. The problems cover a range of fundamental programming concepts including loops, conditional statements, functions, arrays and more.

Uploaded by

Diya Sicily siju
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)
14 views4 pages

C Programming Exercises and Solutions

The document provides 25 coding problems in C language with examples of printing patterns, checking number properties, performing calculations, and converting between bases. The problems cover a range of fundamental programming concepts including loops, conditional statements, functions, arrays and more.

Uploaded by

Diya Sicily siju
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

1.

Write a C program to print your details as follows:

NAME

RNO SCORE

#include<stdio.h>

int main()

printf("name\n");

printf("\nrollno\tSCORE");

return 0;

Output:

2. Write a C program to print the sum of two numbers.

3. Write a C program to find the sum and average of three numbers.

4. Write a C program to convert the temperature in celecius to farenheit.

5. Write a C program to swap two numbers: a. using a temporary variable. b. without using a
temporary variable.

6. Write a C program to check whether a given number is odd or even.

7. Write a C program to check whether a given number is positive, negative or zero.


8. Write a C program to print the largest of three numbers.

9. Write a C program to print the roots of a quadratic equation.

10. Write a C program to input a number from 1-7 and print the corresponding day of the week.
Use switch.

11. Write a C program to input the date and provide the output in words as shown below: Sample
input: Day- 1 Month- 3 Year- 2023 Output: 1st March 2023.

12. Write a C program to print all the even numbers from 2 to 50.

13. Write a C program to print all the numbers from 99 to 1.

14. Write a C program to print the sum of first 'n' natural numbers.

15. Write a C program to find the factorial of a number.

16. Write a C program to check whether a given number is prime or not.

#include<stdio.h>

int main()

int i,n,sum=0;

printf("enter the number");

scanf("%d",&n);

for(i=2;i<n;i++)

if (n%i==0);{

printf("prime");
break;

else

printf("not");

return 0;

17. Write a C program to check whether a given number is armstrong or not.

18. Write a C program to reverse a given number and check whether it is a palindrome or not

19. Write a C program to print the following pattern:

* *

* * *

* * * *

20. Write a C program to print the following pattern: 1 1 2 1 2 3 1 2 3 4

[Link] a C program to print the following pattern:

2 2

3 3 3

4 4 44

22. Write a C program to print the following pattern: 1 2 3 4 5 6


23. Write a C program to print all the prime numbers from 1 to 'n'. Get the value of 'n' from the
user.

24. Write a C program to find the sum of the following series: a. 1+2+3+4+... n 2 b.
12+22+32+42+......n2 c. 1/1! + 2/2! + 3/3! +4/4! +..... n/n! d. x - x3/3! + x5/5! -.......

25. Write a C program to convert a decimal number to its binary representation

You might also like