Programs on If Statement

  1. WAP to read a number and check if it is even or odd
    input:
    Enter a number: 5
    output: number 5 is odd
  2. WAP to read 2 numbers and check if their last digits are same or not
    input:
    Enter number 1: 55
    Enter number 2: 45
    output: Last digits of 55 and 45 are same
  3. WAP to read 3 angles and check if triangle can be formed or not
    input:
    Enter value for angle a: 50
    Enter value for angle b: 60
    Enter value for angle c: 70
    output: Triangle can be formed
  4. WAP to read 3 angles and check if it is and equilateral triangle or not
    input:
    Enter value for angle a: 60
    Enter value for angle b: 60
    Enter value for angle c: 60
    output: Triangle is equilateral triangle
  5. WAP to read marks for 5 subjects and check if student is passed or not
    input:
    Enter marks for maths: 50
    Enter marks for science: 50
    Enter marks for history: 50
    Enter marks for english: 50
    Enter marks for marathi: 50
    output:
    Total Marks: 250
    Percentage: 50%
    Student is passed
  6. WAP to read 2 numbers and find the greatest of them
    input:
    Enter number 1: 50
    Enter number 2: 60
    output:
    60 is greater than 50
  7. WAP to read 3 numbers and find the greatest of them
    input:
    Enter number 1: 50
    Enter number 2: 60
    Enter number 2: 70
    output:
    70 is greater than 50 and 60
  8. WAP to read 3 digit number and check if the sum of cube of its digits is equal to that number or not
    input:
    Enter a 3 digit number: 153
    output:
    Success: Sum of cube of 153 is 153
  9. WAP to read 3 numbers and check their last digit is same or not
    input:
    Enter number 1: 50
    Enter number 2: 60
    Enter number 3: 70
    output:
    Last digits of 50, 60 and 70 are same
  10. WAP to read a number and check if it is palindrome number or not
    input:
    Enter a number: 121
    output:
    121 is palindrome number
  11. WAP to read marks of 5 subjects and print their total. Also print percentage and check if student is passed or not
    input:
    Enter marks for maths: 50
    Enter marks for science: 50
    Enter marks for history: 50
    Enter marks for english: 50
    Enter marks for marathi: 50
    output:
    Total Marks: 250
    Percentage: 50%
    Student is passed
  12. WAP to read 3 angles and check if triangle can be formed or not. If triangle can be formed then check it it is equilateral, isosceles or right angled triangle
    input:
    Enter value for angle a: 45
    Enter value for angle b: 45
    Enter value for angle c: 90
    output:
    Triangle can be formed
    The triangle is right angled triangle
  13. WAP to read age and gender of person and check if person is Eligible for marriage or not
    if gender is male then Eligibility is 21 years
    if gender is female then Eligibility is 18 years
    input:
    Enter gender M or F: M
    Enter your age: 30
    output:
    30 ka ho gaya ab to shadi kar le
  14. WAP to read a year and check if it is Leap year or not
    input:
    Enter year: 2004
    output:
    Year 2004 is a leap year
  15. WAP to read a Salary of Employee and print commission according to following Criteria
    SAL               Commission
    <10000             10%
    10000-20000   12%
    >20000             15%
    input:
    Enter Salary: 10000
    output:
    Your commission is 1000 Rupees
  16. WAP to read percentage of student and print Division
    >=75 : 1st class with distinction
    60-75: 1st class
    50-60: 2nd class
    40-50: 3rd class
    <40: fail
    input:
    Enter marks for maths: 75
    Enter marks for science: 75
    Enter marks for history: 75
    Enter marks for english: 75
    Enter marks for marathi: 75
    output:
    Total Marks: 375
    Percentage: 75%
    Student passed with 1st class Distinction

Leave a Reply

Your email address will not be published. Required fields are marked *