Exercise Questions - If

  1. Input number and find it is odd or even.
  2. Solution: C Python C#

  3. Input year and find it is leap year or not.
  4. Solution: C Python

  5. Input 2 numbers and find greater.
  6. Solution: C Python PHP

  7. Input 2 numbers and find smaller.
  8. Solution: C

  9. WAP to check whether the input number is Positive or Negative.
  10. Solution: C Python

  11. Input user age and find it is eligible for vote or not
  12. Solution: C

  13. Input 3 numbers and find the largest number.
  14. Solution: Python

  15. Input shopping amount and calculate discount, if amount is greater than or equals to 1000 than 15% discount is given otherwise 5%.
  16. Solution: C Python

  17. Input 3 angles of triangle and check whether a triangle is valid or not. A triangle is valid if the sum of all the three angles equal to 180 degrees and no angle is equals to 0.
  18. Input 5 subjects marks of a student and find percentage & grade on the following slabs:
  19. Percentage Grade
    81 - 100 A
    71 - 80 B
    61 - 70 C
    40 - 60 D
    0 - 39 F
  20. WAP to input working hour of a employee and find per day salary on the following conditions:
  21. Percentage Grade
    First 8 hrs Rs 600 per hour
    Next 4 hrs Rs 400 per hour
    Next 4 hrs Rs 300 per hour
    Next 4 hrs Rs 200 per hour

    Solution: C

  22. WAP to input annual salary and calculate tax based on the following slab:
  23. Annual Salary Tax
    Below 50000 Nil
    50001 – 90000 20%
    90001 – 150000 30%
    Above 150001 35%

    Solution: C

  24. WAP to Input the value of basic salary and calculate the HRA, DA, PF and total salary. (Total salary=basic salary + HRA + DA – PF).
  25. Basic salary HRA DA PF
    >25000 10.25% 8.5% 5.5%
    >15000 to <=25000 8.25% 5.5% 3.5%
    >7500 to <=15000 5.5% 3.5% 1.5%
    >=2500 to <=7500 3.5% 2.5% 1.05%
    <2500 2.5% 1.0% 0.5%
  26. WAP to generate electricity bill for n customers, keeping in mind different rates.
  27. Units Rates
    1 - 50 1.45
    51 - 100 2.6
    101 - 200 3.6
    Above 200 6.9

    Solution: C

  28. A cashier has currency notes of denominations 10, 50 and 100. If the amount to be withdrawn is input through the keyboard, find the total number of currency notes of each denomination the cashier will have to give to the withdrawer.