Programming Questions and Exercises : Decision

Programming Questions and Exercises : Decision

Question 1
Write a program that asks the user to enter a number and displays whether entered number is an odd number or even number.
Question 2
Write a program that asks the user to enter a number and displays the absolute value of that number.
Question 3
Revenue can be calculated as the selling price of the product times the quantity sold, i.e. revenue = price × quantity. Write a program that asks the user to enter product price and quantity and then calculate the revenue. If the revenue is more than 5000 a discount is 10% offered. Program should display the discount and net revenue.
Question 4
Write a program that asks the user to enter a numbers in three variables and then displays the largest number.
Question 5
Write a program that prompts the user to input a number. The program should then output the number and a message saying whether the number is positive, negative, or zero.
Question 6
A triangle is valid if the sum of all the three angles is equal to 180 degrees. Write a program that asks the user to enter three integers as angles and check whether a triangle is valid or not.
 
Question 7
Any year is input by the user. Write a program to determine whether the year is a leap year or not.
Leap Years are any year that can be evenly divided by 4.  A year that is evenly divisible by 100 is a leap year only if it is also evenly divisible by 400.
Example :
1992      Leap Year
2000      Leap Year
1900      NOT a Leap Year
Question 8
Write a program to calculate the monthly telephone bills as per the following rule: 
Minimum Rs. 200 for up to 100 calls. 
Plus Rs. 0.60 per call for next 50 calls. 
Plus Rs. 0.50 per call for next 50 calls. 
Plus Rs. 0.40 per call for any call beyond 200 calls.
Question 9
The marks obtained by a student in 3 different subjects are input by the user. Your program should calculate the average of subjects. The student gets a grade as per the following rules:
Average
Grade
90-100
A
80-89
B
70-79
C
60-69
D
0-59
F

Question 10
Write a program that prompts the user to enter grade. Your program should display the corresponding meaning of grade as per the following table
Grade
Meaning
A
Excellent
B
Good
C
Average
D
Deficient
F
Failing

Question 11
Write a program that prompts the user to enter three names. Your program should display the names in descending order.


No comments:

Post a Comment

Pages