SWITCH Statement

  1. WAP to read a single digit number and print that number in words.
  2. WAP to read month in digits print it in words.
  3. WAP to read a single number and print all numbers from 1 to that number in words.
  4. WAP to read a color code (char value) and print appropriate color.
    (e.g. R – Red, G- Green, B-Blue and other char – Black)
  5. WAP to read 2 numbers and a Operator sign and perform the operation according to operator.
    (e.g.
    i/p:
    5
    7
    +

5+7=12
)

  • WAP to count total number of vowels in a string by using a switch statement
  • WAP to count total number of vowels of each type

Loops Programs

EXACT OUTPUT IS OPTIONAL FOR PYTHON AND JAVASCRIPT

  1. WAP to read a number and print all numbers from 1 to that number
    [box title=”” bg_color=”#dbdbdb” align=”left”]input: enter a number: 5
    output:
    1
    2
    3
    4
    5
    [/box]
  2. WAP to read number and print all even numbers from 1 to that number
    [box title=”” bg_color=”#dbdbdb” align=”left”]input: enter a number: 5
    output:
    2
    4
    [/box]
  3. WAP to print all number from 1 to 10 by using while, for and do -while loop.
  4. WAP to read a number and find sum of all numbers from 1 to that number
    [box title=”” bg_color=”#dbdbdb” align=”left”]input: enter a number: 5
    output: 1 + 2 + 3 + 4 + 5 = 15
    [/box]
  5. WAP to read a number and find factorial of that number
    [box title=”” bg_color=”#dbdbdb” align=”left”]input: enter a number: 5
    output: 1 * 2 * 3 * 4 * 5 = 120
    [/box]
  6. WAP to read a number and check if it is a prime number or not
    [box title=”” bg_color=”#dbdbdb” align=”left”]input: enter a number: 5
    output: 5 is a prime number
    [/box]
  7. WAP to print all prime number in range from 1 to 100
    [box title=”” bg_color=”#dbdbdb” align=”left”]output: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97
    [/box]
  8. WAP to print first 10 fibonacci number
    [box title=”” bg_color=”#dbdbdb” align=”left”]output: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55
    [/box]
  9. WAP to print table of number in following format using 1 for loop
    input: enter a number: 5
    [box title=”” bg_color=”#dbdbdb” align=”left”]5 * 1 = 5 5 * 10 = 50
    5 * 2 = 10 5 * 9 = 45
    5 * 3 = 15 5 * 8 = 40
    5 * 4 = 20 5 * 7 = 35
    5 * 5 = 25 5 * 6 = 30
    5 * 6 = 30 5 * 5 = 25
    5 * 7 = 35 5 * 4 = 20 
    5 * 8 = 40 5 * 3 = 15
    5 * 9 = 45 5 * 2 = 10
    5 * 10 = 50 5 * 1 = 5
    [/box]
  10. WAP to create random jackpot number and take input from user to guess the number. Based on level the attempt to guess the number should change
    1. Easy – 20 attempts
    2. Medium – 10 attempts
    3. Difficult – 5 attempts
  11. WAP to execute Fizz Buzz Problem / Print number 1 to 100
    1. if number is divisible by 3 then print Fizz
    2. if number is divisible by 5 then print Buzz
    3. if number is divisible by both 3 and 5 then print Fizz Buzz

Programs on If Statement

  1. WAP to read a number and check if it is even or odd[box title=”” bg_color=”#dbdbdb” align=”left”]input:
    Enter a number: 5
    output: number 5 is odd
    [/box]
  2. WAP to read 2 numbers and check if their last digits are same or not[box title=”” bg_color=”#dbdbdb” align=”left”]input:
    Enter number 1: 55
    Enter number 2: 45
    output: Last digits of 55 and 45 are same
    [/box]
  3. WAP to read 3 angles and check if triangle can be formed or not[box title=”” bg_color=”#dbdbdb” align=”left”]input:
    Enter value for angle a: 50
    Enter value for angle b: 60
    Enter value for angle c: 70
    output: Triangle can be formed
    [/box]
  4. WAP to read 3 angles and check if it is and equilateral triangle or not[box title=”” bg_color=”#dbdbdb” align=”left”]input:
    Enter value for angle a: 60
    Enter value for angle b: 60
    Enter value for angle c: 60
    output: Triangle is equilateral triangle
    [/box]
  5. WAP to read marks for 5 subjects and check if student is passed or not[box title=”” bg_color=”#dbdbdb” align=”left”]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
    [/box]
  6. WAP to read 2 numbers and find the greatest of them[box title=”” bg_color=”#dbdbdb” align=”left”]input:
    Enter number 1: 50
    Enter number 2: 60
    output:
    60 is greater than 50
    [/box]
  7. WAP to read 3 numbers and find the greatest of them[box title=”” bg_color=”#dbdbdb” align=”left”]input:
    Enter number 1: 50
    Enter number 2: 60
    Enter number 2: 70
    output:
    70 is greater than 50 and 60
    [/box]
  8. WAP to read 3 digit number and check if the sum of cube of its digits is equal to that number or not[box title=”” bg_color=”#dbdbdb” align=”left”]input:
    Enter a 3 digit number: 153
    output:
    Success: Sum of cube of 153 is 153
    [/box]
  9. WAP to read 3 numbers and check their last digit is same or not[box title=”” bg_color=”#dbdbdb” align=”left”]input:
    Enter number 1: 50
    Enter number 2: 60
    Enter number 3: 70
    output:
    Last digits of 50, 60 and 70 are same
    [/box]
  10. WAP to read a number and check if it is palindrome number or not[box title=”” bg_color=”#dbdbdb” align=”left”]input:
    Enter a number: 121
    output:
    121 is palindrome number
    [/box]
  11. WAP to read marks of 5 subjects and print their total. Also print percentage and check if student is passed or not[box title=”” bg_color=”#dbdbdb” align=”left”]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
    [/box]
  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[box title=”” bg_color=”#dbdbdb” align=”left”]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
    [/box]
  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[box title=”” bg_color=”#dbdbdb” align=”left”]input:
    Enter gender M or F: M
    Enter your age: 30
    output:
    30 ka ho gaya ab to shadi kar le
    [/box]
  14. WAP to read a year and check if it is Leap year or not[box title=”” bg_color=”#dbdbdb” align=”left”]input:
    Enter year: 2004
    output:
    Year 2004 is a leap year
    [/box]
  15. WAP to read a Salary of Employee and print commission according to following Criteria
    SAL               Commission
    <10000             10%
    10000-20000   12%
    >20000             15%[box title=”” bg_color=”#dbdbdb” align=”left”]input:
    Enter Salary: 10000
    output:
    Your commission is 1000 Rupees
    [/box]
  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[box title=”” bg_color=”#dbdbdb” align=”left”]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
    [/box]

Basic Programs

  1. WAP to read radius of circle and calculate Area and Circumference
    [box title=”” bg_color=”#dbdbdb” align=”left”]i/p:
    Enter radius: 5
    o/p:
    Area of circle is 31.5
    Circumference of circle is 78.5[/box]
  2. WAP to read 3 numbers and find their mean[box title=”” bg_color=”#dbdbdb” align=”left”]i/p:
    Enter number 1: 5
    Enter number 2: 6
    Enter number 3: 7
    o/p:
    Mean of 5, 6 and 7 is 6[/box]
  3. WAP to read 2 numbers and find Sum of their last digit[box title=”” bg_color=”#dbdbdb” align=”left”]i/p:
    Enter number 1: 52
    Enter number 2: 65
    o/p:
    2 + 5 = 7[/box]
  4. WAP to read 4 digit number and sum of its digits[box title=”” bg_color=”#dbdbdb” align=”left”]i/p: Enter a number: 1234
    o/p:
    1 + 2 + 3 + 4 = 10[/box]
  5. WAP to read radius of Sphere and find its Volume[box title=”” bg_color=”#dbdbdb” align=”left”]i/p:
    Enter radius: 5
    o/p:
    Volume of sphere having radius 5 is 523.6[/box]
  6. WAP to read 3 digit number and sum of its digit[box title=”” bg_color=”#dbdbdb” align=”left”]i/p:
    Enter a number: 123
    o/p:
    1 + 2 + 3 = 6[/box]
  7. WAP to read 4 digit number and find reverse of that number[box title=”” bg_color=”#dbdbdb” align=”left”]i/p:
    Enter a number: 1234
    o/p:
    Reverse of 1234 is 4321[/box]
  8. WAP to read temperature in degree Celsius and convert it into Fahrenheit[box title=”” bg_color=”#dbdbdb” align=”left”]i/p:
    Enter temperature in Celsius: 38
    o/p:
    Temperature in Fahrenheit is 100.4[/box]
  9. WAP to read value in inches and print it in feet and inches[box title=”” bg_color=”#dbdbdb” align=”left”]i/p:
    Enter length in inches: 20
    o/p:
    20 inches is equal to 1 foot and 8 inches[/box]
  10. WAP to read marks of 5 subjects and print total and percentage[box title=”” bg_color=”#dbdbdb” align=”left”]i/p:
    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
    o/p:
    Total Marks: 250
    Percentage: 50%[/box]
  11. WAP to read 2 numbers and exchange their values using third variable[box title=”” bg_color=”#dbdbdb” align=”left”]i/p:
    Enter value for x: 5
    Enter value for y: 6
    o/p:
    After swapping value of x is 6 and value of y is 5[/box]
  12. WAP to read 2 numbers and exchange their values without using third variable[box title=”” bg_color=”#dbdbdb” align=”left”]i/p:
    Enter value for x: 5
    Enter value for y: 6
    o/p:
    After swapping value of x is 6 and value of y is 5[/box]
  13. WAP to read Lenght, Breadth and Height and find its volume and surface area[box title=”” bg_color=”#dbdbdb” align=”left”]i/p:
    Enter length: 5
    Enter breadth: 6
    Enter height: 7
    o/p:
    Volume of box is 210
    Surface are of box is 214[/box]

[toggle title=”Solutions”]

# WAP to read radius of circle and calculate Area and Circumference
radius = 5;
area = 3.14 * radius * radius;
print (area);
circumference = 2 * 3.14 * radius;
print (circumference);

# WAP to read marks of 5 subjects and print total and percentage
m = 50;
s = 50;
h = 50;
e = 50;
ma = 50;

total_m = m + s + h + e + ma;
print(total_m);

per = total_m/5;
print(per);

# WAP to read 2 numbers and exchange their values using third variable
x = 5;
y = 6;
z = 0;
z = y;
y = x;
x = z;
print(x,y);

# WAP to read 2 numbers and exchange their values without using third variable
x = 5;
y = 6;

print(x,y);
x = (x*y);
y = (x/y);
x = (x/y);

print(x,y);

# WAP to read Lenght, Breadth and Height and find its volume and surface area

l = 5;
b = 6;
h = 7;

vol = l * b * h;
print(vol);

sa = (2 * l * b) + (2 * l * h) + (2 * b * h);
print(sa);

#WAP to read 3 numbers and find their mean
x = 5;
y = 6;
z = 7;
mean = (x+y+z)/3;
print(mean);

# WAP to read 2 numbers and find Sum of their last digit
x = 52;
y = 65;
sum = x%10 + y%10
print(sum);
# WAP to read 4 digit number and sum of its digits

num = 1234;

n1 = num//1000;

n2 = (num//100) % 10;

n3 = (num//10) % 10;

n4 = num % 10;

total = n1 + n2 + n3 + n4;

print(total);

#WAP to read radius of Sphere and find its Volume
radius = 5;
vol = (4/3) * 3.14 * radius * radius * radius;
print(vol);

# WAP to read 3 digit number and sum of its digit
num = 123;

n1 = num//100;

n2 = (num//10) % 10;

n3 = num % 10;

total = n1 + n2 + n3;

print(total);

# WAP to read 4 digit number and find reverse of that number
num = 1234;

n1 = num//1000;

n2 = (num//100) % 10;

n3 = ( num//10) % 10;

n4 = num % 10;

rev = n4 * 1000 + n3 * 100 + n2 * 10 + n1;

print(rev);

#WAP to read temperature in degree Celsius and convert it into Fahrenheit
c = 38;
F = (38*9/5)+32;
print(F);

#WAP to read value in inches and print it in feet and inches
li = 20;
ft = 20%12;
print(ft);
[/toggle]