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
    input: enter a number: 5
    output:
    1
    2
    3
    4
    5
  2. WAP to read number and print all even numbers from 1 to that number
    input: enter a number: 5
    output:
    2
    4
  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
    input: enter a number: 5
    output: 1 + 2 + 3 + 4 + 5 = 15
  5. WAP to read a number and find factorial of that number
    input: enter a number: 5
    output: 1 * 2 * 3 * 4 * 5 = 120
  6. WAP to read a number and find reverse of that number (optional)
    input: enter a number: 1234
    output: 4321
  7. WAP to read a number and check if it is a prime number or not
    input: enter a number: 5
    output: 5 is a prime number
  8. WAP to print all prime number in range from 1 to 100
    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
  9. WAP to print first 10 fibonacci number
    output: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55
  10. WAP to read a number and find sum of its digits (optional)
    input: 12345
    output: 1 + 2 + 3 + 4 + 5 = 15
  11. WAP to find a 3 digit armstrong number (optional)
    output: 153
  12. WAP to print all armstrong numbers from 1 to 999(optional)
    output: 153, 370, 371, 407
  13. WAP to print ASCII chars and values from 1 to 255
  14. WAP to print alphabets from A to Z using loop
  15. WAP to read a number and count all numbers which divides the given number perfectly
  16. WAP to read 2 numbers and print their common factors
  17. WAP to read 2 numbers and print HCF
  18. WAP to print factorial of all numbers from 1 to 10
  19. WAP to read 2 numbers a and b and print all numbers from a to b
  20. WAP to repeatedly read a number until it is in range from 10 to 20
  21. WAP to read a number and print all numbers which divides the given number perfectly
  22. WAP to find sum of series
    S = 1 + 2 + 3 + …. + N
  23. WAP to find sum of series
    S = 1 + 2! + 3! + …. N!
  24. WAP to find sum of series
    S = 1 + 1/2 + 1/3 + 1/4 + 1/5 + …. + 1/N
  25. WAP to find sum of series
    S = 1 – 1/2 + 1/3 – 1/4 + 1/5 – …. 1/N
  26. WAP to read a number and print tables from 1 to that number
  27. WAP to print following output
    • 12345
      1234
      123
      12
      1
    • 54321
      4321
      321
      21
      1
    • *****
      ****
      ***
      **
      *
    • 1234554321
      1234554321
      1234554321
      1234554321
      1234554321
    • 12345123451234512345
      12345123451234512345
      12345123451234512345
    • ABCDE
      ABCD
      ABC
      AB
      A
    • ABCDEFEDCBA
      ABCDE  EDCBA
      ABCD      DCBA
      ABC           CBA
      AB                BA
      A                     A
    • *********
        *******
         *****
          ***
            *
  28. WAP to print table of number in following format using 1 for loop
    input: enter a number: 5
    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
  29. 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
  30. 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

Leave a Reply

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