KEMBAR78
If - Else Programs Sheet | PDF | Economies
0% found this document useful (0 votes)
30 views7 pages

If - Else Programs Sheet

The document outlines a series of programming tasks focused on decision-making in programming. Each task requires writing a program to perform specific checks or calculations based on user input, covering various topics such as number properties, triangle types, grading systems, and financial calculations. The tasks are intended for practice in conditional statements and basic programming logic.

Uploaded by

vanshpatel3424
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views7 pages

If - Else Programs Sheet

The document outlines a series of programming tasks focused on decision-making in programming. Each task requires writing a program to perform specific checks or calculations based on user input, covering various topics such as number properties, triangle types, grading systems, and financial calculations. The tasks are intended for practice in conditional statements and basic programming logic.

Uploaded by

vanshpatel3424
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

DECISION MAKING PROGRAMS

Q1. Write a program to input a number and check it is even or odd number or not.
Q2. Write a program to input two numbers and check which is greater or both are equal.
Q3. Write a program to input a number and check it positive or negative of zero.
Q4. Write a program to input cost price and selling price, compute and display profit and
profit % or loss and loss % or print a message no profit no loss.
Q5. Write a program to input three numbers and check which is largest.
Q6. Write a program to input three sides of triangle and check it is Equilateral or Isosceles or
Scalene triangle.
Q7. Write a program to input three sides of triangle and check it is Right Angle Triangle or
not.
Q8. Write a program to input three sides and check it can form a triangle or not.
Q9. Write a program to input three coefficients a, b, c of a quadratic equation ax2 + bx + c=0.
Calculate it roots and display it according to the following data:

Where D=b2-4ac
i) If D>0 then roots are real and distinct.
ii) If D=0 then roots are real and equal.
iii) If D<0 then roots are imaginary.
Q10. WAP to read the sides of triangle, check and print triangle is possible or not?
Q11. WAP to read the sides of triangle, check and print triangle is possible or not? If possible
then check and print whether it is equilateral, isosceles, scalene triangle or not?
Q12. Write a program to input an integer and check whether it is positive, negative or Zero,
using conditional operator.
Q13. Write a program to input an integer and check whether it is positive, negative or Zero,
using if-else.
Q14. Write a program to input a digit(0-9) and print it in words using switch- case. In case a
valid digit is not entered, it should print message “Not a Valid Input”.
Q15. Write a program to input a digit(0-9) and print it in words using if-else-if ladder. In case a
valid digit is not entered, it should print message “Not a Valid Input”.
Q16. Write a program to input a day number(1-7) and print it in words using switch- case. In
case a valid day is not entered, it should print message “Not a Valid day number”.
Q17. Write a program to input a day number(1-7) and print it in words using if-else- if ladder.
In case a valid day is not entered, it should print message “Not a Valid Input”.
Q18. Write a program to input a month number(1-12) and print it in words using switch- case.
In case a valid month is not entered, it should print message “Not a Valid Input”.
Q19. Write a program to input a month number(1-12) and print it in words using if-else-if
ladder. In case a valid month is not entered, it should print message “Not a Valid Input”.
Q20. Write a program to input any character check and print whether it is vowel or not using
switch- case.

1|
//Character based program
Q21. Write a program to input any character check and print whether:-
i) it is vowel or not ?
ii) it is consonant or not?
iii) It is upper case letter or not?
iv) It is lower case letter or not?
v) It is alphabet or not?
vi) It is digit or not?
vii) It is space character or not?
viii) Special character or not?

Q22. WAP to read the following types of 2 values. Check and print the highest and lowest
between them using if-else.
i) numbers
ii) ages
iii) salaries
iv) prices
v) heights
vi) weights
vii) temperatures
viii) scores
ix) marks

Q23. WAP to read the following types of 3 values. Check and print the highest and lowest
between them using if-else.
i) numbers
ii) ages
iii) salaries
iv) prices
v) heights
vi) weights
vii) temperatures
viii) scores
ix) marks
Q24. WAP to read the following types of 2 values, Check and print the highest and lowest
between them using ternary operator.
i) Number
ii) Ages
iii) Salaries
iv) Prices
v) Heights
vi) Weights
vii) Temperatures
viii) Scores
ix) marks

2|
Q25. WAP to read the following types of 3 values, Check and print the highest and lowest
between them using ternary operator.
i) numbers
ii) ages
iii) salaries
iv) prices
v) heights
vi) weights
vii) temperatures
viii) scores
ix) marks
Q26. Write a program to input the marks in English and find the grade obtained depending
upon the following criteria:

Marks in English Grade


90 and above A
70 to 89 B
50 to 69 C
35 to 49 D
Below 35 E
Q27. Write a program to input the name and marks in 3 subjects of a student and find the grade
obtained depending upon the average marks scored and print it along with Student name.

Average Marks Grade


90% and above A
70% to 89% B
50% to 69% C
35% to 49% D
Below 35% E
Q28. Write a program to input the name of the customer, quantity and unit price of product.
Calculate and print total amount payable by the customer along with name.
Q29. Write a program to input the name of the customer, quantity and unit price of product.
Calculate and print total amount payable by the customer along with name according to
the given details.
Total amount Discount
<= 5000 Nil
<= 15000 3.7%
<=30000 5.9%
>30000 6.85%
Q30. Write a program to input the name of the salesman, and the sales amount. Calculate and
print total commission along with name according to the given details.
Sales Amount Commission
<= 50000 2.5%
<= 300000 3.25%

3|
<=500000 5.0%
>500000 6.75%
Q31. Write a program to input the name of the employee, and the monthly income. Calculate
and print annual income and tax payable along with name according to the given details.
Annual Income Tax rate
<= 300000 Nil
<= 500000 2.25%
<=1000000 5.0%
>1000000 7.75%
Q32. Write a program to input the name of the employee, and the monthly income. Calculate
and print monthly savings along with name according to the given details.

Monthly Income Electricity exp. Milk exp. Food exp. savings


<= 10000 8.5% 13.65% 23.0%
<= 25000 10.25% 16.5% 29%
<=50000 15.0% 21.25% 33.6%
>50000 17.75% 23.45% 40.0%
Savings = Monthly Income-(Electricity exp+ Milk exp. + food Exp)
Q33. Write a program to input the name of the employee, and the monthly income. Calculate
and print Gross salary along with name according to the given details.

Monthly Income DA HRA PF Gross Salary


<= 10000 8.5% 13.65% 8.33%
<= 25000 10.25% 16.5% 8.33%
<=50000 15.0% 21.25% 8.33%
>50000 17.75% 23.45% 8.33%
Gross Salary = Monthly Income+ DA + HRA - PF
Q34. Write a program to input the name of the student, name of the book and days delay to
return the book to library. Calculate and print the fine payable by student along with
name according to the given details.

Days (delay) Fine per day


First 5 days ` 1.5/ day
Next 10 days `2.50/ day
Above 15 days `5.0/ day
Q35. Write a program to input the name of the consumer, meter number and consumed units of
electricity. Calculate and print the charge payable by consumer along with other details
according to the given details in the following format.

Units (consumed) charge per day


first 100 units ` 1.5/ unit
next 200 units ` 3.5/ unit
next 150 units ` 4.5/ unit
above 450 units `6.0/ unit

4|
Output format:
Name meter number consumed unit’s electricity charge
………. …………… …………….. ……………...

Q36. Write a program to input the name of the consumer, weight of parcel. Calculate and print
the parcel charge payable by consumer along with other details according to the given
details in the following format.

weight (in grams) charge per gram


first 100 grams ` 0.5/ gram
next 150 grams ` 0.85/ gram
next 200 grams ` 1.25/ gram
above 450 grams `1.50/ gram
Output format:
Name Parcel weight Parcel charge
………. …………… …………..

Q37. Write a program to input the name of the passenger, train number, distance traveled.
Calculate and print the fare payable by passenger along with other details according to
the given details in the following format.

distance (in kms) fare per km


first 50 kms ` 0.85/ km
next 100 kms ` 1.65/ km
next 200 kms ` 2.25/ km
above 350 grams ` 3.5/ km
Output format:
Name Train number Distance traveled Fare
………. …………… ………….. ……

Q38. Write a program to input the name of the consumer, mobile number and calls made.
Calculate and print the mobile bill payable by consumer along with other details
according to the given details.

Mobile calls charge per call


first 100 calls ` 0.65/ call
next 200 calls ` 1.25/ call
next 150 calls ` 2.5/ call
above 450 calls ` 3.0/ call

Q39. Shasha Travels Pvt. Ltd. Gives the following discount to its customers.

Ticket amount Discount


Above ` 70000 18%
`55001 to 70000 16%

5|
`35001 to 55000 12%
`25001 to 35000 10%
Less than ` 25001 6%
Write a program to input the name and ticket amount for the customer and calculate the
discount amount and net amount to be paid.

Q40. A cloth showroom has announced the following festival discount on the purchase of
items based on the total cost of the item purchased.
Total Cost Discount
Upto ₹ 2000 5%
₹ 2001 to ₹ 5000 25 %
₹ 5001 to ₹ 10000 35 %
Above ₹ 10000 50 %
Write a program to input the total cost and to compute and display the amount to paid by
the customer after availing discount.

Q41. Write a program to input name of customer, telephone number, number of calls made by
customer and compute the amount of bill to paid by customer according to following
slab:
Number Of Calls Rate
First 100 Calls ₹ 250 rental only
Next 100 Calls Rental + 60 paisa per call
Next 100 Calls Rental + ₹ 1.2 per call
Next 100 Calls Rental + ₹ 1.8 per call
Above 400 Calls Rental + ₹ 2.5 per Call
Display the amount of bill to paid by the customer along with name and telephone
number in following format:
Name Telephone No. Amount
------- ----------------- ------------
Q42. Monthly electric bill is calculated as follows:
Number Of Units Rate
<=100 units Only meter rent ₹ 200
For next 200 units meter rent + ₹ 3.5 per unit
For next 200 units meter rent + ₹ 4.5 per unit
Above 500 units meter rent + ₹ 5.0 per unit
Write a program to input consumer number, name and number of units consumed and
calculate the amount of bill to be paid in the following format:
Consumer No. Name No. of Units. Bill
------------- ------- ------------- -----

Q43. An electronic shop has announced the following seasonal discount on the purchase of
certain items:

Purchase Amount (₹) Discount on Laptop Discount on Desktop

6|
0-25000 0.0% 5%
25001-57000 5.0% 7.5%
57001-100000 7.5% 10%
More than 100000 10% 10.5%
Write a program based on the above criteria, to input name, address, amount of purchase
and type of purchase (L for Laptop and D for Desktop) by the customer. Compute and
print the net amount to be paid by customer along with his/her name and address.

Q44. The tax department has announced the net tax rate and deduction as per following rules:

Gross Annual income (₹) Tax rate for female Tax rate for male
Upto 175000 Nill Nill
175001-350000 10% 12%
350001-550000 20% 22%
550000 and above 30% 33%

Write a program to input name, pan number, gross monthly income and gender (F for
female and M for male). Compute the annual income taxable income and tax to be paid
using the above criteria. Print name, pan number, gross annual income, taxable income
and tax to be paid.
Q45. A company provides motorbike on rent to its members only. Write a program to input
bike number(int bkno), Id number(int idno), phone number(int phno), number of days(int
days) for which bike is taken on rent, calculate the charge(int charge) according to
following criteria:
Number of Days Rate
First 5 days ₹ 500 per day
Next 5 days ₹ 400 per day
Rest of the days ₹ 200 per day
Print the output in the following format:
Bike No. Phone No. Member Id No. No. of days Rent
-------- ---------- -------------- ------------ -----
Q46. A hotel has following special rates for stay depending upon number of days:
Number of days Rate
First 3 days ₹ 350 per day
For next 3 days ₹ 300 per day
For next 3 days ₹ 275 per day
Any day beyond 9 days ₹ 225 per day
Write a program to input name of person, number of days stayed, room number allotted,
check-in date and check out date. Calculate checkout bill amount and print it with all
above given details.

7|

You might also like