Practice Questions
1. WAP to enter 10 numbers and find and display average
of odds and evens separately.
2.
2. WAP to enter a number and check if it is prime or not.
2.1 WAP to display all primes less than 100
2.2 WAP to display first 50 primes.
3. WAP to enter as many positive numbers. End the loop if 0
or negative is entered. Finally display the average of all
entered positive numbers.
4. WAP to display a multiplication table upto 10 for a user
input number.
5. Display all Armstrong numbers from 1 to 1000. An
Armstrong number is one whose sum of cubes of its digits is
equal to the number. For eg. 371 = 33+73+13
6. Write a program to reverse an integer and print it.
Eg. Input Output
51 15
849 948
-512 -215
7. Consider the following algorithm:
Start with a positive number n
if n is even then divide by 2
if n is odd then multiply by 3 and add 1
continue this until n becomes 1
Input a positive number and generate the series given above.
8. Enter a number and find the next perfect square number.
Eg. Next perfect square of 5 is 9, 20 is 25, 36 is 49, 0 is 1, -9 is 0.