C Programming Manual
C Programming Manual
C Programming Manual
STUDENT MANUAL
Example
1. Flowchart c program to find area of circle
2. C program to check input year is leap year or not
Exercise
Draw a flowchart to determine
1. Area of square
2. Volume of cuboid
3. Volume of sphere
4. Volume of cylinder
5. maximum of two number
6. Citizen is eligible for voting or not
7. Student is lean or fat
8. Number is positive or negative
9. Student is pass or fail
2 Week 2-Using Printf Statements.
1. Write a program that prints the numbers 1 to 4 on the same line using one printf
statement.
2. Write a program that prints the following shapes with asterisks
3. Display the following checkerboard pattern with eight printf statements and then display
the same pattern with one printf statements
3 Week 2-Using Variables & Operators.
1. Write a program that asks the user to enter two numbers, obtains them from the user
and prints their sum, product, difference, quotient and remainder.
2. Write a program that reads in the radius of a circle and prints the circle’s diameter,
circumference and area. Use the constant value 3.14159 for π. Perform each of these
calculations inside the printf statement(s) and use the conversion specifier %f.
3. Write a program that calculates the squares and cubes of the numbers from 0 to 10 and
uses tabs to print the following table of values
4. Create an application that calculates your daily driving cost, so that you can estimate
how much money could be saved by car -pooling, which also has other advantages such
as reducing carbon emissions and reducing traffic congestion. The application should
input the following information and display the user’s cost per day of driving to work:
a) Total KMs driven per day.
b) Cost per gallon of gasoline.
c) Average KMs per gallon.
d) Parking fees per day.
e) Toll cost per day.
5. Create a BMI calculator application that reads the user’s weight in kilograms and height
in meters), then calculates and displays the user’s body mass index. Use the formulae
The application should display the following information based on the users BMI
6. Write a C program that convert a temperature from Centigrade to Fahrenheit. Use
C = (5/9) * (F - 32)
Expected Output :
Input a temperature (in Centigrade): 45
113.000000 degrees Fahrenheit.
Output
8. Write a C program that prints the perimeter of a rectangle to take its height and width
as input.
Expected Output:
Input the radius of the sphere: 2.56
The volume of sphere is 70.276237.
Output
9. Write a C program that converts kilometers per hour to miles per hour.
Expected Output :
Input kilometers per hour: 15
9.320568 miles per hour
Output
10. Write a C program that takes hours and minutes as input, and calculates the total
number of minutes.
Expected Output :
Input hours: 5
Input minutes: 37
Total: 337 minutes
Output
11. Write a program in C that takes minutes as input, and display the total number of hours
and minutes.
Expected Output :
Input minutes: 546
9 Hours, 6 Minutes
Output
12. Write a program in C to calculate the sum of three numbers with getting input in one
line separated by a comma.
Expected Output :
Input three numbers separated by comma : 5,10,15
The sum of three numbers : 30
Output
13. Write a C program to perform addition, subtraction, multiplication and division of two
numbers.
Expected Output :
Input any two numbers separated by comma : 10,5
The sum of the given numbers : 15
The difference of the given numbers : 5
The product of the given numbers : 50
The quotient of the given numbers : 2.000000
Output
14. Write a C program to find the third angle of a triangle if two angles are given. Expected
Output :
Input two angles of triangle separated by comma: 50,70
Third angle of the triangle: 60
Output
15. Write a program in C that reads a forename, surname and year of birth and display the
names and the year one after another sequentially. Go to the editor
Expected Output :
Input your firstname: Tom
Input your lastname: Davis
Input your year of birth: 1982
Tom Davis 1982
Output
4 Week 3-Using Control Statements.
1. Write a C program to accept two integers and check whether they are equal or not
Test Data : 5,6
Expected Output :
Number1 and Number2 are equal
Output
Solution
4. Write a C program to find whether a given year is a leap year or not. Go to the editor
Test Data : 2016
Expected Output :
2016 is a leap year.
Code
Output
5. Write a C program to read the age of a candidate and determine whether it is eligible for
casting his/her own vote.
Test Data : 21
Expected Output :
Congratulation! You are eligible for casting your vote
Code
Output
6. Write a C program to read the value of an integer m and display the value of n is 1 when
m is larger than 0, 0 when m is 0 and -1 when m is less than 0.
Test Data : -5
Expected Output :
The value of n = -1
Code
Output
7. Write a C program to accept the height of a person in centimeter and categorize the
person according to their height as shown
Output
9. Write a C program to find the eligibility of admission for a technology/engineering
course based on the following criteria:
Marks in Maths >=65
Marks in Phy >=55
Marks in Chem>=50
Total in all three subject >=180
or
Total in Math and Physics >=140
Code
Output
Output
10. Write a program that asks the user to enter two integers, obtains the numbers from the
user, then prints the larger number followed by the words “is larger.” If the numbers are
equal, print the message “These numbers are equal.”
11. Write a program that inputs three different integers from the keyboard, then prints the
sum, the average, the product, the smallest and the largest of these numbers. Use only
the single-selection form of the if statement you learned in this chapter.
12. Write a program that reads an integer and determines and prints whether it’s odd or
even.
5 Week 4-Using Loop Statements.
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
Code
Solution
Output
4. Write a program in C to display the cube of the number upto given an integer. Test Data:
Input number of terms : 5
Expected Output :
Number is : 1 and cube of the 1 is :1
Number is : 2 and cube of the 2 is :8
Number is : 3 and cube of the 3 is :27
Number is : 4 and cube of the 4 is :64
Number is : 5 and cube of the 5 is :125
Code
Solution
Solution