Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

20 Exercise Questions for C Programming

1. Enter two numbers A and B. Please exchange their values and output

them.

2. Input two numbers A and B., please output which is small and which

is big (Please use pointer and function to solve this question).

3. Judge the prime numbers between 101 and 200 and output them.

4. Print all "Narcissus Numbers". The so-called "Narcissus Number"

refers to a three-digit number whose sum of each digital cube is

equal to that number. For example, 153=1 3+53+33 , so 153 is a

"Narcissus Number".

5. Decomposition of a positive integer into some prime factors. For

example, input 90, then output 90=2*3*3*5.

6. Enter the student's score, if the score >= 90, output the grade in A,

60-89 in B and below 60 in C.

7. Input two positive integers m and n to find the greatest common

divisor.

8. Input two positive integers m and n to find the least common

multiple.

9. Find the sum of s, s=a+aa+aaa+aaaa+aa…a, where a is a number, for

example: s = 2 + 22 + 222 + 2222, finally the s is 2468. How many a

will be added can be determined by input (n).

10. A number, if it is exactly equal to the sum of its factors, is called a


"perfect number". For example, 6 = 1 + 2 + 3, find out all the

complete numbers within 1000.

11. A ball falls freely from a height of 100 meters. After each landing, it

bounces half of its original height and then falls. How many meters

did it pass when it landed for the tenth time?

12. Find the sum of 1 + 2 + 3 +... + 100.

13. Find the sum of 1! + 2! + 3! +... + 20!.(Please define a function to

calculator each of factorials)

14. Find the sum of x+x2/2+x3/3+…+x10/10, x is an integer which can be

obtained by input.

15. There is a sequence: 2/1, 3/2, 5/3, 8/5, 13/8, 21/13... Find the sum of

the first 20 entries in this sequence.

16.Enter 10 numbers, define the sort function to sort them in

descending order and then output them.

17. Input 10 numbers find out the maximum, minimum, average and

output.

18. Enter 10 numbers and output them in reverse order. For example,

12,23,34,33,17,then the output is:17,33,34,23,12

19. Verification: An even number can always be expressed as the sum of

two prime numbers.

20.Input a number m, and then print out all prime numbers which are

less than m (Please use pointer and function to solve this question).

You might also like