Categories

# Assignments

#### Conditional statements

1. Write a program to check a number is divisible by 7 or not.
2. Write a program to check a number is factor of 84 or not.
3. Write a program to check a number is factor of 96 or not and if the given number is more Than 96 program should say ‘not a valid input’.
4. Write a program to check a number is multiple of 3 or not.
5. Write a program to check a number is positive or not.
6. Write a program to check a number is having 4 at units place (984).
7. Write a program to check a number is 3 digited number or not.
8. Write a program to print even or odd for a given number.
9. Write a program to print the greatest number in given two numbers.
10. Write a program to print the least number in given two numbers.
11. Write a program to print the given two numbers in ascending order.
12. Write a program to print the given two numbers in descending order.
13. Write a program to print the greatest number in given three numbers.
14. Write a program to print the least number in given three numbers.
15. Write a program to print the given three numbers in ascending order.
16. Write a program to print the given three numbers in descending order.
17. Write a program to take marks of three subjects and print the grade of student.
18. Write a program to check whether a number is a perfect square.
19. Write a program to check whether a number is a perfect cube.
20. Write a program to check whether an array contains a perfect square and is also an odd number at the last index.
21. Write a program to print only the multiples of 2 and 3 between 1 and 50.
22. Write a program to check whether an array contains strings.
23. Write a program to print only those numbers from an array that contain 2 or 4 in the unit’s place.
24. Write a program to check whether all the numbers in an array are prime or not.
25. Write a program to check whether any string in an array has the letter ‘i’ in it.
26. Write a program to check whether the first and last elements in an array are boolean values.
27. Write a program to print all the multiples of 2 that don’t contain 0 at the unit’s place between 1 and 50.

## Loop statements

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. Write a program to print factors of 24 using while loop(factors of 24 are 1,2,3,4,6,8,12,24).
10. Write a program to print the number of factors of 24 using while loop(number of factors for 24 is 8).
11. Write a program to print 1 to 10 numbers using a for loop.
12. Write a program to print 10 to 1 numbers using a for loop.
13. Write a program to print all numbers from 1 to a given number.
14. Write a program to print 1 to 10 even numbers using a for loop.
15. Write a program to print 1 to 10 odd numbers using a for loop.
16. Write a program to print first 10 multiples of 3.
17. Write a program to print multiplication table of 6.
18. Write a program to print factorial of a given number.
19. Write a program to print all the factors of a given number.
20. Write a program to print the count of factors of a given number.
21. Write a program to check a given number is a prime number or not.
22. Write a program to print reverse of digits of a number.
23. Write a program to read 5 numbers and print the maximum and minimum number.
24. Write a program to read 5 numbers and print the sum of all entered numbers.
25. Write a program to print average of n numbers.
26. Write a program to read 5 numbers and print only the even numbers.
27. Write a program to print the Fibonacci number series up to a given number.
28. Write a program to check a given number is Armstrong number or not.
29. Write a program to print the reverse of a given number.
30. Write a program to check a given number is palindrome number or not.
31. Write a program to print the number at 100’s place.
32. Write a program to print the nCr of given ‘n’ and ‘r’ values.
33. Print the largest digit of given number.
34. Print the number of digits in a given number.
35. Print the sum of all digits of a given number.
36. Print the binary value of 8.
37. Write a program to print only even digits of a given number.
38. Write a program to print only odd digits of a given number.
39. Write a program to print only digits out of a given string.(For example: ‘MH43AB3209’)
40. Print the squares of all numbers from 1 to 10.
41. Print the cubes of all numbers from 1 to 10.
42. Write a program to find the sum of all prime numbers between 1 and 50.
43. Write a program to find the product of all odd numbers between 1 and 10.
44. Write a program to count the number of ‘1’s in a given number.
45. Write a program to eliminate all zeroes from a given number.
46. Write a program to print all the digits that are less than 5 in a given number.

More loops assignments