conditional structure problems

1
The University of Lahore The Department of Computer Science & IT LAB MANUAL-2(Control Structure) 1. Write a program that asks the user to enter two integers, obtains the numbers from the user, and thenprints the larger number followed by the words “is larger”. If the numbers are equal, print the message “These numbers are equal”. 2. If cost price and selling price of an item is input through the keyboard, write a program to determine whether the seller has made profit or incurred loss. Also determine how much profit he made or loss he incurred. 3. Any integer is input through the keyboard. Write a program to find out whether it is an odd number or even number. 4. A five-digit number is entered through the keyboard. Write a program to obtain the reversed number and to determine whether the original and reversed numbers are equal or not. 5. If the ages of Ram, Shyam and Ajay are input through the keyboard, write a program to determine the youngest of the three 6. Write a program to check whether a triangle is valid or not, when the three angles of the triangle are entered through the keyboard. A triangle is valid if the sum of all the three angles is equal to 180 degrees. 7. Given the length and breadth of a rectangle, write a program to find whether the area of the rectangle is greater than its perimeter. For example, the area of the rectangle with length = 5 and breadth = 4 is greater than its perimeter. 8. Given the length and breadth of a rectangle, write a program to find whether the area of the rectangle is greater than its perimeter. For example, the area of the rectangle with length = 5 and breadth = 4 is greater than its perimeter. 9. Write a program that reads an integer and determines whether it is odd or even. 10. Write a program to determine which character is entered by the user from the keyboard i.e., an uppercase character, a lowercase character, a digit or a special symbol. 11. Write a program that inputs a six digit number from the user reverses it and determines if the original and reverse numbers are equal or not. Do not allow the user to enter any other number except a six digit number.

Upload: university-of-lahore

Post on 23-Jan-2018

119 views

Category:

Presentations & Public Speaking


0 download

TRANSCRIPT

Page 1: Conditional structure problems

The University of Lahore

The Department of Computer Science & IT

LAB MANUAL-2(Control Structure)

1. Write a program that asks the user to enter two integers, obtains the numbers from the

user, and thenprints the larger number followed by the words “is larger”. If the numbers

are equal, print the message “These numbers are equal”.

2. If cost price and selling price of an item is input through the keyboard, write a program to

determine whether the seller has made profit or incurred loss. Also determine how much

profit he made or loss he incurred.

3. Any integer is input through the keyboard. Write a program to find out whether it is an

odd number or even number.

4. A five-digit number is entered through the keyboard. Write a program to obtain the

reversed number and to determine whether the original and reversed numbers are equal or

not.

5. If the ages of Ram, Shyam and Ajay are input through the keyboard, write a program to

determine the youngest of the three

6. Write a program to check whether a triangle is valid or not, when the three angles of the

triangle are entered through the keyboard. A triangle is valid if the sum of all the three

angles is equal to 180 degrees.

7. Given the length and breadth of a rectangle, write a program to find whether the area of

the rectangle is greater than its perimeter. For example, the area of the rectangle with

length = 5 and breadth = 4 is greater than its perimeter.

8. Given the length and breadth of a rectangle, write a program to find whether the area of

the rectangle is greater than its perimeter. For example, the area of the rectangle with

length = 5 and breadth = 4 is greater than its perimeter.

9. Write a program that reads an integer and determines whether it is odd or even.

10. Write a program to determine which character is entered by the user from the keyboard

i.e., an uppercase character, a lowercase character, a digit or a special symbol.

11. Write a program that inputs a six digit number from the user reverses it and determines if

the original and reverse numbers are equal or not. Do not allow the user to enter any other

number except a six digit number.