Java Practice Questions on iteration with while and for loops

  1. Write a program to print 1 to 10 numbers using a while loop
  2. Write a program to print 10 to 1 numbers using a while loop
  3. Write a program to print 5 to 15 numbers using a while loop
  4. Write a program to print 15 to 10 numbers using a while loop
  5. Write a program to print 1 to 10 even numbers using a while loop
  6. Write a program to print 1 to 10 odd numbers using a while loop
  7. Write a program to print first ten multiples of 4 using a while loop (multiples of 4 are 4,8,12,16,20,…..)
  8. Write a program to print multiplication table of 6 using while loop
  9. Print the squares of all numbers from 1 to 10.
  10. Print the cubes of all numbers from 1 to 10.
  11. Write a program to print factors of 24 using while loop (factors of 24 are 1,2,3,4,6,8,12,24)
  12. Write a program to print 1 to 10 numbers using a for loop
  13. Write a program to print 10 to 1 numbers using a for loop
  14. Write a program to print all numbers from 1 to a given number
  15. Write a program to print 1 to 10 even numbers using a for loop
  16. Write a program to print 1 to 10 odd numbers using a for loop
  17. Write a program to print first 10 multiples of 3 using a for loop
  18. Write a program to print multiplication table of 6 using a for loop
  19. Write a program to print all the factors of a given number
  20. a program to read 5 numbers and print the maximum and minimum number
  21. a program to read 5 numbers and print only the even numbers
  22. Print all the digits of a given number
  23. Write a program to print only even digits of a given number The output should be 4,2,6 Ex. Let us take 154256
  24. Write a program to print only odd digits of a given number Ex. Let us take 1542763 The output should be 1,5,7,3
  25. Write a program to print the number at 10’s place
  26. Write a program to print the number at 100’s place
  27. Write a program to print the number at 1000’s place
  28. Write a program to print the number at 10000’s place
  29. Write a program to find the LCM of given two numbers
  30. Write a program to convert an octal number to a decimal
  31. Write a program to print the sum of 1 to 10 ( initialisation of sum variable with 0 )
  32. Write a program to print the average of 1 to 10
  33. Accumulation
  34. Write a program to print the sum of the numbers between the given two numbers
  35. Write a program to print the sum of even numbers between the given two numbers
  36. Write a program to print the sum of odd numbers between the given two numbers
  37. Write a program to print the product of the numbers between 1 to 10 ( initialisation of product variable with 1 )
  38. Write a program to find the product of all odd numbers between 1 and 10.
  39. Write a program to print the nth power of a given number. n can be any positive number. (n=3 r =4 then answer must be 333*3 )
  40. Write a program to print factorial of a given number
  41. Write a program to print the nCr of given ‘n’ and ‘r’
  42. Write a program to print the number of factors of 24 using while loop (number of factors for 24 is 8)
  43. Write a program to print the count of factors of a given number using for loop
  44. Write a program to check a given number is a prime number or not
  45. a program to read 5 numbers and print the sum of all entered numbers
  46. a program to read 5 numbers and print average of n numbers
  47. print Number of Digits in given number.
  48. Write a program to count the number of ‘1’s in a given number.
  49. Write a program to eliminate all 0’s from a given number.
  50. Write a program to print all the digits that are less than 5 in a given number.
  51. Print the greatest digit of a given number(n=1237456 then greatest digit is 7)
  52. sum of all digits of a given number Ex: let us take 19345 is the given number The output should be 22 (1+9+3+4+5)=22
  53. a program to print reverse of digits of a number
  54. print the binary value of 8.
  55. Write a program to convert a binary number into a decimal number
  56. Write a program to check a given number is palindrome number or not
  57. Write a program to check a given number is armstrong number or not Ex:153 is an armstrong number
  58. Write a program to print the fibonacci number series up to a given number Expected output:0 1 1 2 3 5 8 13
  59. Print A Calendar Taking Input From User Using Loop

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

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