C Programming Practical Questions with solutions| C Programming Exercises, Practice, Solution

1. Write a C Program to print Welcome to C Programming.

Output:

Welcome to C Programming

2. Write a program in C to print the following:

Welcome to C Programming

It is invented by Denis Ritche

It is portable, flexible and versatile

Output:

Welcome to C Programming

It is invented by Denis Ritche

It is portable, flexible and versatile

3. Write a C program to print the following:

Welcome to

             C Programming

Invented by

          Denis Ritche

Output:

Welcome to

        C Programming

Invented by

        Denis Ritche

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

OR

Write a program in C to add two numbers.

OR

Output:

Result: 18

5. Write a C program to add two numbers taking input from user.

Output:

Enter 1st number: 34

Enter 2nd number: 45

Result: 79

OR

Output:

Enter two numbers: 34 45

Result: 79

6. Write a C program to display sum and difference of two numbers.

Output:

Sum: 17

Difference: 3

OR

Output:

Enter two numbers: 34 23

Sum: 57

Difference: 11

7. Write   a program in C to store two integer values in two variables and using them calculate addition, subtraction, multiplication and division.

Output:

Enter two integer values: 56 34

Addition= 90

Subtraction= 22

Multiplication= 1904

Division= 1

8. Write a program in C to find the average of three numbers.

Output:

Enter three numbers: 4 6 7

Average: 5.67

9. Write a C program to calculate the square of a number.

Output:

Enter a number: 7

Square of 7 is 49

10. Write a program in C to convert Rupees into Paisa.

OR

Write a C program to read the price of an item in rupees in decimal format and prints the output in paisa.

OR

Write a C program to read a price of an item in (float) like 10.25 and print output in (int) paisa like1025.

OR

Make a program in C to enter the amount in Rupees and print into paisa.

Output:

Enter price of the item in Rupees: 20.50

Price of the item in Paisa: 2050

11. Write a program in C to find the distance travelled in miles given the speed and time. The speed is 4.5 MPH and time is 2.1 sec.

Output:

The distance travelled is:9.45

12. Write a C program to find the Kinetic Energy of a particle. Given the Mass and Velocity as 14 and 3.

Output:

Kinetic Energy:63.000

13. Write a program in C to calculate Kinetic Energy of a particle.

         

Output:

Enter the mass: 25

Enter the velocity: 5

Kinetic Energy:312.500

14. Write a C program to calculate total marks and percentage of 5 subjects of a student.

Output:

Enter english marks: 67

Enter maths marks: 78

Enter physics marks: 85

Enter chemistry marks: 87

Enter computer science marks: 92

———————————

Total marks obtained: 409.00

Percentage: 81.80

OR

Output:

Enter marks of 5 subjects: 55 65 45 70 85

———————————

Total marks obtained: 320.00

Percentage: 64.00

15. Write a program in C to input name and marks of the student and print the statement of marks.

Output:

Enter name of the student: Pramila Barla

Enter english marks: 78

Enter maths marks: 67

Enter science marks: 85

—————————

Name: Promila Barla

English marks: 78

Maths marks: 67

Science marks: 85

—————————

Total marks obtained: 230.00

Percentage: 76.67

16. Write a program in C to print a pay-slip using the following data:

Employee Number is 100

BASIC Salary is 35000

DA must be calculated as 10% of BASIC

HRA must be calculated as 20% of BASIC

Total Salary must be calculated as BASIC+DA+HRA

Output:

Employee Number: 100

Basic Salary: 40000

Dearness Allowance: 4000.00

House Rent Allowance: 8000.00

Total Salary: 52000.00

17. The basic salary of an employee is input through the keyboard. The DA is 15% of the basic salary while the HRA is 25% of the basic salary. Write a program to in C calculate his total salary. Total Salary must be calculated as BASIC+DA+HRA

OR

Output:

Enter Basic salary: 40000

—————————-

Basic Salary: 40000.00

Dearness Allowance: 6000.00

House Rent Allowance: 10000.00

—————————-

Total Salary: 56000.00

18. Write a C program to calculate simple interest.

OR

Write a program in C to find the simple interest.

Output:

Enter principal amount: 4000

Enter rate of interest: 4

Enter time period in years: 2

—————————————–

Simple Interest is: 320.00

19. Write a C program to calculate the area of a triangle. (Formula: area=1/2*base*height)

Output:

Enter the base of the triangle: 4.5

Enter the base of the triangle: 8

Area of the triangle: 18.00

20. Write a program in C to calculate and display the area and circumference (perimeter) of a circle by accepting the radius from the user. (Formula: Area: πr2, π=22/7, Circumference: 2πr)

Output:

Enter the radius of the circle: 2.7

Area of the circle: 22.91

Circumference of the circle: 16.97

21. Write a C program that reads the side of a square and calculates the area and perimeter of square and prints them.

Output:

Enter the length of side of square: 10

Area of the square: 100.000

Perimeter of the square: 40.000

22. Write a C program to calculate the volume of a sphere. (Formula: v = 4/3πr³, where v= volume and r = radius.

Output:

Enter the radius of the sphere: 6

Volume of the sphere: 904.896

23. Write a C program to convert temperature from Celsius to Fahrenheit.

Output:

Enter temperature in Celsius: 37

Temperature in Fahrenheit: 98.600

24. Write a C program to convert the normal body temperature of a man from Fahrenheit to Celsius.

OR

Write a C program to convert temperature from Fahrenheit to Celsius degree.

Output:

Enter temperature in Fahrenheit: 98.6

Temperature in Celsius: 37.000

25. Write a program in C to calculate and print the function value after evaluating:

y=x2 + 2x -3           at x=4

Output:

The function value is: 21

Leave a Comment