# C Programming Exercises on Numbers: Exercises, Practice, Solution

## C Programming Exercises on Numbers: [37 exercises with solution]

[An editor is available at the bottom of the page to write and execute the scripts.]

1. Write a program in C to check whether a given number is an ugly number or not. Go to the editor

Expected Output :
Input an integer number: 25
It is an ugly number.

Click me to see the solution

2. Write a program in C to check whether a given number is Abundant or not. Go to the editor

Expected Output :
Input an integer number: 18
The number is Abundant.

Click me to see the solution

3. Write a program in C to find the Abundant numbers (integers) between 1 to 1000. Go to the editor

Expected Output :
The Abundant number between 1 to 1000 are:
-----------------------------------------------
12 18 20 24 30 36 40 42 48 54 56 60 66 70 72 78 80...

Click me to see the solution

4. Write a program in C to check whether a given number is Deficient or not. Go to the editor

Expected Output :
Input an integer number: 15
The number is Deficient.

Click me to see the solution

5. Write a program in C to find the Deficient numbers (integers) between 1 to 100. Go to the editor

Expected Output :
The Deficient numbers between 1 to 100 are:
------------------------------------------------
1 2 3 4 5 7 8 9 10 11 13 14 15 16 17 19 21 22 23 25 26 27...

Click me to see the solution

6. Write a program in C to check whether a given number is a Kaprekar number or not. Go to the editor

Expected Output :
Input a number: 45
45 is a Kaprekar number.

Click me to see the solution

7. Write a program in C to generate and show all Kaprekar numbers less than 1000. Go to the editor

Expected Output :
The Kaprekar numbers less than 1000 are:
1 9 45 55 99 297 703 999

Click me to see the solution

8. Write a program in C to check whether a number is Lychrel number or not. Go to the editor

Expected Output :
Input a number: 196
The given number is Lychrel.

Click me to see the solution

9. Write a program in C to display and count the number of Lychrel numbers within a specific range(from 1 to a specific upper limit). Go to the editor

Expected Output :
Input the upper limit: 1000
The Lychrel numbers are:
196 295 394 493 592 689 691 788 790 879 887 978 986
The number of Lychrel numbers are: 13

Click me to see the solution

10. Write a program in C to generate and show the first 15 narcissistic decimal numbers. Go to the editor

Expected Output :
The first 15 narcissistic decimal numbers are:
1 2 3 4 5 6 7 8 9 153 370 371 407 1634 8208

Click me to see the solution

11. Write a program in C to display the first 10 lucus numbers. Go to the editor

Expected Output :
The first 10 Lucus numbers are:
2 1 3 4 7 11 18 29 47 76

Click me to see the solution

12. Write a program in C to display the first 10 catlan numbers. Go to the editor

Expected Output :
The first 10 catlan numbers are:
1 1 2 5 14 42 132 429 1430 4862

Click me to see the solution

13. Write a program in C to check a number is a Happy or not. Go to the editor

Expected Output :
Input a number: 13
13 is a Happy number.

Click me to see the solution

14. Write a program in C to find the happy numbers between 1 to 1000. Go to the editor

Expected Output :
The happy numbers between 1 to 1000 are: 1 7 10 13 19 23 28 31 32 44 49.....

Click me to see the solution

15. Write a program in C to check whether a number is Desoriam or not. Go to the editor

Expected Output :
Input a number: 135
The given number is a Disarium Number.

Click me to see the solution

16. Write a program in C to find Disarium numbers between 1 to 1000. Go to the editor

Expected Output :
The Disarium numbers are:
1 2 3 4 5 6 7 8 9 89 135 175 518 598

Click me to see the solution

17. Write a program in C to check if a number is Harshad Number or not. Go to the editor

Expected Output :
Input a number: 9
The given number is a Harshad Number.

Click me to see the solution

18. Write a program in C to find Harshad Number between 1 to 100. Go to the editor

Expected Output :
The Harshad Numbers are: 1 2 3 4 5 6 7 8 9 10 12 18 20 21 24 27 30 36 40 42 45 48 50 54 60 63 70 72 80 81 84 90 100

Click me to see the solution

19. Write a program in C to check whether a number is a Pronic Number or Heteromecic Number or not. Go to the editor

Expected Output :
Input a number: 132
The given number is a Pronic Number.

Click me to see the solution

20. Write a program in C to find Pronic Number between 1 to 1000. Go to the editor

Expected Output :
The Pronic numbers are: 2 6 12 20 30 42 56 72 90 110 132 156 182 210 240 272 306 342 380 420 462 506 552 600 650 702 756 812 870 930 992

Click me to see the solution

21. Write a program in C to check if a number is Authomorphic or not. Go to the editor

Expected Output :
Input a number: 76
The given number is an Automorphic Number.

Click me to see the solution

22. Write a program in c++ to find the the Authomorphic numbers between 1 to 1000. Go to the editor

Expected Output :
The Authomorphic numbers are: 1 5 6 25 76 376 625

Click me to see the solution

23. Write a program in C to check whether a number is a Duck Number or not. Go to the editor

Expected Output :
Input a number: 3210
The given number is a Duck Number.

Click me to see the solution

24. Write a program in C to find Duck Numbers between 1 to 500. Go to the editor

Expected Output :
The Duck numbers are: 10 20 30 40 50 60 70 80 90 100 101 102......

Click me to see the solution

25. Write a program in C to check two numbers are Amicable numbers or not. Go to the editor

Expected Output :
Input the 1st number : 1184
Input the 2nd number : 1210
The given numbers are an Amicable pair.

Click me to see the solution

26. Write a program in C to count the amicable pairs in an array. Go to the editor

Expected Output :
Input the number of elements to be stored in the array: 4
element - 0: 220
element - 1: 274
element - 2: 1184
element - 3: 1210
Number of Amicable pairs presents in the array: 1

Click me to see the solution

27. Write a program in C to check if a given number is circular prime or not. Go to the editor

Expected Output :
Input a Number: 1193
The given number is a circular prime Number.

Click me to see the solution

28. Write a program in C to find circular prime numbers upto a specific limit. Go to the editor

Expected Output :
Enter the upper Limit: 1000
The Circular Prime Numbers less than 1000 are:
2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 311 337 373 719 733 919 971 991

Click me to see the solution

29. Write a program in C to check whether a given number is a perfect cube or not. Go to the editor

Expected Output :
Input a number: 125
The number is a perfect Cube of 5

Click me to see the solution

30. Write a program in C to display first 10 Fermat numbers. Go to the editor

Expected Output :
The first 10 Fermat numbers are:
3.000000
5.000000
17.000000
257.000000
65537.000000
4294967297.000000
18446744073709551616.000000
340282366920938463463374607431768211456.000000
115792089237316195423570985008687907853269984665640564039457584007913129639936.000000
13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858 186486050853753882811946569946433649006084096.000000
inf

Click me to see the solution

31. Write a program in C to find any number between 1 and n that can be expressed as the sum of two cubes in two (or more) different ways. Go to the editor

Expected Output :
The numbers in the above range are:
1729 = 1^3 + 12^3 = 9^3 + 10^3
4104 = 2^3 + 16^3 = 9^3 + 15^3
13832 = 2^3 + 24^3 = 18^3 + 20^3
39312 = 2^3 + 34^3 = 15^3 + 33^3
46683 = 3^3 + 36^3 = 27^3 + 30^3
32832 = 4^3 + 32^3 = 18^3 + 30^3
40033 = 9^3 + 34^3 = 16^3 + 33^3
20683 = 10^3 + 27^3 = 19^3 + 24^3
65728 = 12^3 + 40^3 = 31^3 + 33^3
64232 = 17^3 + 39^3 = 26^3 + 36^3

Click me to see the solution

32. Write a program in C to Check if a number is Mersenne number or not. Go to the editor

Expected Output :
Input a number: 127
127 is a Mersenne number.

Click me to see the solution

33. Write a program in C to generate mersenne primes within a range of numbers. Go to the editor

Expected Output :
Input a upper limit [range from 1 to upper limit]: 1000
Mersenne prime numbers are:
3 7 31 127

Click me to see the solution

34. Write a program in C to find narcissistic decimal numbers within a specific range. Go to the editor

Expected Output :
Input the lower limit: 100
Input a upper limit: 1000
The narcissistic decimal numbers between 100 and 1000 are:
153 370 371 407

Click me to see the solution

35. Write a program in C to print the first 20 numbers of the Pell series. Go to the editor

Expected Output :
The first 20 numbers of Pell series are:
0 1 2 5 12 29 70 169 408 985 2378 5741 13860 33461 80782 195025 470832 1136689 2744210 6625109

Click me to see the solution

36. Write a program in C to check if a number is Keith or not. Go to the editor

Expected Output :
Input a number : 1104
The given number is a Keith Number.

Click me to see the solution

37. Write a program in C to check if a number is Keith or not(with explanation). Go to the editor

Expected Output :
Input a number : 1537
1 + 5 + 3 + 7 = 16
5 + 3 + 7 + 16 = 31
3 + 7 + 16 + 31 = 57
7 + 16 + 31 + 57 = 111
16 + 31 + 57 + 111 = 215
31 + 57 + 111 + 215 = 414
57 + 111 + 215 + 414 = 797
111 + 215 + 414 + 797 = 1537
The given number is a Keith Number.

Click me to see the solution

C Code Editor:

More to Come !