Professional Documents
Culture Documents
The aims of this lab are to cover some other basics of C programming Decision Control Structures in
detail.
Comparison/Relational Operators
Logical Operators
If Statement
If - else statement
Comparison/Relational Operators
Not equal to a != b
Equal to a == b
Logical Operators
Logical OR a || b
Lab Tasks
Task 1:
Write a program which takes two numbers from the keyboard, and determine and display which
(if either) is the larger of the two numbers.
Sample Output
Task 2:
Write a program which takes year as an input through the keyboard then it determines whether the
year is a leap year or not.
Hint:(The year is evenly divisible by 4 and 400 but not divisible by 100 is said to be leap year.
Use the % (modulus) operator).
Sample Output
Task 3:
Write a program to check whether a triangle is valid or not, when the three angles of the triangle are entered
through the keyboard.
Hint: A triangle is valid if the sum of all the three angles is = 180
Sample Output
Task 4:
Write a program which takes input from the keyboard and determine whether it is an even or odd number.
Program to find even number
**********************
Enter the Number: 90
The date June 10, 1960, is special because when we write it in the following format, the month times the
day equals the year.
6/10/60
Write a program that asks the user to enter a month (in numeric form), a day, and a two-digit year. The
program should then determine whether the month times the day is equal to the year. If so, it should display
a message saying the date is magic. Otherwise, it should display a message saying the date is not magic.
Sample Output(Case 1)
Sample Output(Case 2)
Bonus Task 2:
The area of a rectangle is the rectangle’s length times its width. Write a program that asks for the length
and width of two rectangles. The program should tell the user which rectangle has the greater area, or if the
areas are the same.
Sample Output(Case 2)