Cpps Practice Questions
Cpps Practice Questions
Unit:1,2
Division:A,C
Practice Question :
2. Write a program that reads two numbers and divides the first number by the second
number. If division is not possible print "Division is not possible".
3. Write a C program to read the coordinates (x, y) (in the Cartesian system) and find the
quadrant to which it belongs (Quadrant -I, Quadrant -II, Quadrant -III, Quadrant -IV).
Note: A Cartesian coordinate system is a coordinate system that specifies each point
uniquely in a plane by a pair of numerical coordinates.
These are often numbered from 1st to 4th and denoted by Roman numerals: I (where
the signs of the (x,y) coordinates are I(+,+), II (−,+), III (−,−), and IV (+,−).
4. Write a C program to read a password(int) until it is valid. For wrong password print
"Incorrect password" and for correct password print, "Correct password" and quit the
program. The correct password is 1234.
5. Write a C program to check whether a given integer is positive even, negative even,
positive odd or negative odd. Print even if the number is 0.
6. . Write a C program that reads an integer between 1 and 12 and prints the month of the
year in English.
Test
Data:
Input a number between 1 to 12 to get the month name:
8
ExpectedOutput:
August
7. Write a C program to convert a given integer (in seconds) to hours, minutes and
seconds.
Test
8. Data :
Inputseconds:25300
ExpectedOutput:
9. Write a C program to convert a given integer (in days) to years, months and days,
assuming that all months have 30 days and all years have 365 days.
TestData :
Inputno.ofdays:2535
ExpectedOutput:
6Year(s)
11Month(s)
15 Day(s)
10. Write a C program to calculate a bike’s average consumption from the given total
distance (integer value) travelled (in km) and spent fuel (in litters, float number – 2
decimal points).
TestData:
Input total distance in km: 350
Input total fuel spent in liters: 5
ExpectedOutput:
Average consumption (km/lt) 70.000
11. Write a C program that accepts two integers from the user and calculates the product of
thetwointegers.
TestData :
Input the first integer: 25
Input the second integer: 15
ExpectedOutput:
Product of the above two integers = 375
13. Write C Program to Find the Size of int, float, double, and char.