0% found this document useful (0 votes)
5 views3 pages

C Programming Exercises for Beginners

Uploaded by

bella.shine7799
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)
5 views3 pages

C Programming Exercises for Beginners

Uploaded by

bella.shine7799
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 program to assigned values to three variables at the time


of declaration. Print the assigned values on the computer screen.

2. Write a program to print a message "C language is a powerful


programing language." on screen.

3. Write a program to assign two varibles by assignment statement.


Interchange the values and print the result on the screen.

4. Write a program to assign the numeric value to a variable year.


Calculate the number of months, and print on the screen.

5. Write a program to get two numbers. Calculate the sum and


product of the numbers and then print the result on the screen.

6. Write a program to get age (in years) of a person. Calculate the


age in months and print the age in months.

7. Write a program to get the Roll No. of a student and marks


obtained in three subject Programming Fundamentals,
Introduction to Computing and Computer Graphics. Calculate the
Total and Average. Each subject has a maximum of 100 marks.

8. Write a program to get temperature in Fahrenheit. Convert the


temperature to Celsius degrees by using the formula.
C = 5/9(f - 32)

9. Write a program to find the maximum number from four


numbers.

10. Wirte a program to convert 2.5 miles into kilometers and print
the result on screen. (Hint: 1 mile = 1.609 kilometers)

11. Write a program to declare and initialize two variables of "int"


type. Calculate the average of these values and print the result
on screen.

12. Write a program to find the volume of a cylinder by using 'const'


qualifier. The formula to find the volume of a cylinder is:
Volume ¿ π R 2 xH The value of π is3.1417

13. Write a program using define directive to find the area of a circle.
The formula to find the area ofa circle is:
Area ¿ π R 2 The value of π is 3.1417
14. Write a program to convert millimeters into inches and print the
result on screen. (Hint: 1 inch = 25.4 mm)

15. Write a program to interchange values of two variables.

16. Write a program to assign a value 3 to "int" type variables a, b


and c using multiple assignment statement. Calculate the
product of these numbers.

17. Write a program to separate the integral and fractional parts of a


15.58971 real number and print the result on screen.

18. Write a program to assign values to variables 'vi' and 't' an


compute the value of 's' by using the formula:
1 2
S=vi∗t+ at
2

19. Write a program to assign your age in a variable and find the age
in months and days.

20. Write a program to print the output as given under by using


escape sequence.
C:\Windows>
'P' 'A' 'K'
"Pakistan"

21. Write a program to print the output as shown below using '\n'
escape sequence (without using loop and use one printf
statement)
XXXXX
XXXX
XXX
XX
X

22. Write a program to input the name, age, height and gender of
the student and prints the data of student on screen.

23. Write a program to input the radius of a circle and calculate area
& circumstance of the circle.
Formula for Area of a circle ¿ π R 2
Formula for Circumference of a circle ¿ 2 πR

24. Write a program to input marks of five subjects of a student.


Calculate the Total and Average marks. (Each subject has weight
of 100 marks).
25. Write a program to input the values of three sides of a triangle
and calculate its area using the formula:
Area = √ s ( s−a )( s−b ) (s−c ) where s = (a+b+c)/2

26. Write a program to convert 12000 rupees into dollars (1 dollar =


Rs. 60)
27. Write a program to input time in hours, minutes and seconds.
Convert time into seconds and print the result on screen.

28. Write a program to input values into variables a, b and c.


Compute the value of 'disc' by using formula: disc = b 2 - 4ac

29. Write a program to print a message if the value of variable "n" is


greater than 100, otherwise ignore the statement.

30. Write a program to test whether a given integer is odd or even


using simple 'if' structure.

You might also like