Assignment2 7n3quest (Practical3)
Assignment2 7n3quest (Practical3)
Practical 3
Data types,Variables,Equations, If /Else
01. Write a program that print any two integer numbers, three decimal numbers (use float) and
four characters.
02. Write a program that enters any two numbers and get their average. (Use key board inputs)
04. Write a program that converts inches to centimeters. For example, if the user enters 16.9 for a
Length in inches, the output would be 42.926cm.
(Hint: 1 inch = 2.54 centimeters)
05. Given as input an integer number of seconds, print as output the equivalent time in hours,
minutes and seconds. Recommended output format is something like:
7322 seconds is equivalent to 2 hours 2 minutes 2 seconds.
06. Write and run a program that prints the sum, difference, product, quotient and remainder of
two integers. Take values for the integers from the keyboard.
[Hint: quotient = (m/n) and remainder = (m%n)] .
1
Control Structures (if - else)
if(condition)
Statement
else(condition)
statement
1. Write and run a program that reads the user’s age and then prints
a. You are a Child. - If the age<18
b. You are a Senior citizen-If age>=18
2. Write and run a program that reads the user’s age and then prints
a. You are a Child. - If the age<18
b. You are an Adult-If18<=age<65
c. You are a Senior citizen- If age>=65
3. The marks (M1, M2, M3) obtained by a student in 3 different subjects are input through the
keyboard. The students are categorized as per the following rules.
a. Average above or equal to 75-A
b. Average between 55 and 74 – B
c. Average between 40and 54-C
d. Average below 40-F
4. Write and run a program that simulates a simple calculator. It reads two integers and a
character.
a. If the character is a +, the sum is printed;
b. If it is a -, the difference is printed;
c. If it is a *, the product is printed;
d. If it is a /, the quotient is printed
e. If it is a %, the remainder is printed