Computer Exercises and Reference Answers in C Language Programming
Computer Exercises in C Language Programming
1. Given the three sides a, b, and c of the triangle, find the area of the triangle (you should first judge whether the three sides a, b, and c can form a triangle).
2. A kindergarten only accepts children from 2 to 6 years old. 2 to 3 years old is placed in a small class, 4 years old is placed in a middle class, and 5 to 6 years old is placed in a large class. The programming realizes that each age is entered, and what class should be placed in the output. .
3. Write a program, input an integer, determine whether it is divisible by 3, 5, and 7, and output the following information according to the situation: (1) It can be divided by 3, 5, and 7 at the same time; (2) It can be divided by 3, 5 at the same time. , 7 are divisible by two numbers, and output the two numbers; (3) can only be divisible by one of 3, 5, and 7; (4) cannot be divisible by any of 3, 5, and 7.
4. Please list all two-digit numbers whose single digit is 6 and which is divisible by 3.
5. Find the sum of the reciprocals of the numbers from 1 to 500 that are divisible by 5.
6. Write a program, input the grades of several students in a certain course, take -1 as the final value, calculate the average grade and output.
7. If you put 12 balls, 3 red balls, 3 white and 6 black balls in your pocket, take any 8 of them, write a program, and list all possible ways of taking them.
8. Write a program and ask for 2012! How many zeros are there at the end of ?
9. When the last digits of the square of a natural number are the same as the number, the number is called an isomorphic number. For example: 252=625, then 25 is an isomorphic number. Program to find isomorphic numbers from 1 to 1000.
10. Enter a larger integer and find the maximum 5 prime numbers less than the integer.
n11. Find the approximate value of the following sequence: S=1-1/22+1/33-1/44+ (-1)/nn. Input precision
degrees, and the calculation stops when the precision of an item is less than this value.
float fun(float esp)
{ }
void main()
{float esp;
scanf(“%f”,&esp);
printf(“%f\n”,fun(esp));}
12. Write a function change(int x,int r) to convert the decimal integer x to r(1
13. Find the intimate number pairs within 1000. The definition of intimate number pair is: if the sum of all factors of integer a (excluding itself) is b, the sum of all factors of b (excluding b itself) is a, and a and b are not equal, then a and b are called are close pairs. int fun(int x)
{ }
void main()
{int n,a,b;