Write A Program That Let The User To Enter The Temperature As An Integer Number

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

ADVANCED COMPUTER PROGRAMMING

LABORATORY EXERCISE NO. 2


IF STATEMENTS

1. Write a program that let the user to enter the temperature as an integer number,
then if this number is greater than or equal to 20°C, the program should display “The
weather is hot.”, or if this number is less than or equal to 0°C, the program should
display “The weather is cold.”. Otherwise, the program should display “The weather
is normal.”. The numbers should be between -50 and +50. Your program should
control this condition too. If the user does not enter number which is between them,
you should print to the screen
“Invalid number.”

2. Write a program that user inputs an integer number. Then, your program should
act the absolute function in mathematic. It means that if the number is negative, it
should convert to positive number. At the end, you print the number to the
screen.

3. Write a program that reads the marks of a student, determine and prints the
equivalent grade, based on the following:

Marks Range Grade

< 45 E

45 <= Marks < 60 D

60 <= Marks < 75 C

75 <= Marks < 90 B

Marks >= 90 A

4. Write a program that reads a positive single-digit integer number between 1 – 7


and prints the corresponding day of the week (1 is Monday). For example, if the
user enters 3, the program should print the word “Tuesday” to the screen. Please
include proper input validation.

5. Write a program that reads three integer numbers, and then prints the
largest and the smallest number.

6. A line in its slope-intersect form is defined by y=ax+b. In this equation a is slope


of the line and b is y intersection. To find out if a point (x,y) is on the line, the
coordinates of the point is used in the equation. If the equality is established then
the point is on the line. Write a program to read a and b parameters of a line.
Then read the coordinates of a point and verify if it is on the line or not.

7. Write a C program to input three values and determine if they represent the
three sides of a triangle. The three values represent a triangle if sum of two
smallest values are greater than the third one and the difference between the
largest and smallest values should be less than the third value.

You might also like