nC programming NCIT
Lab Exercise 1
1. Write a program which displays: This is the first programming lab exercise.
2. Write printf command to display the following:
a. To display your name.
b. To display your section.
c. To display your age.
Note: All the information should be printed on a new line.
3. Write a program which displays: * * * * *
4. Write program which displays:
*
* * *
* * * * *
* * *
*
5. Write scanf commands for the following
a. To ask Name of a person.
b. To ask age of a person.
c. To ask section of a person.
d. To ask salary of a person, which is in format 5000.65?
6. Write a program find to addition, subtraction, multiplication and division of two numbers
entered by the user.
7. Write a program to calculate the surface area of cube. [Hint area=6l2]
8. Calculate the area and circumference of the circle.
9. The length and breadth are input through the keyboard. Write a program to calculate the
area and perimeter of the rectangle.
10.Write a program to divide one integer by another integer and find the quotient and
remainder.
11. Write a program to convert km entered by user to cm.
12.Write a program to convert entered number of seconds into hours, minutes and seconds.
13. Write a program to convert entered number of days into years, months and days.
14. Write a program to convert length from mm to km, m, cm and mm.
15. Write a program to input two digit numbers and reverse the number.
16. Write a program to input two numbers from the keyboard and interchange the contents of
the two variable.
17. Write a program that takes input from the user by using getchar( ) function and prints it
on the screen by using putchar( ) function.
18. Write a program that takes text from the user by using gets( ) function and print that text
n the screen using puts( ) function.
19. If the marks obtained by a student in five different subjects are input through the
keyboard, find out the aggregate marks and percentage marks obtained by the student.
Assume that the maximum marks obtained by a student in each subject are 100.
20. Write a program that will convert temperature in Centigrade into Fahrenheit.
[Hint: C=5/9(F-32) and F=9/5C+32]
21. Write a program that asks three coefficients of a quadratic equation and calculate its root.
22. Write a program to read three sides of a triangle and calculate the area.
[Hint: Area=√s(s-a)(s-b)(s-c)]
23. Two numbers are input through the keyboard. Write a program to interchange the
the contents.
25. If a five-digit number is entered through the keyboard, write a program to calculate the
the sum of its digits.
26. If a five digit number is entered through the keyboard. Write a program to reverse the
number.
27. If a four digit number is entered through the keyboard. Write a program to find the sum
of first and last digit of this number.