# 829 postgraduate entrance examination questions of Hunan University in 2010

## 1, Single choice questions (12 * 3 = 36)

1. The C language source program file is compiled and linked by the C compiler to generate a suffix of____ File( C )
A. " .c "
B. " .obj "
C. " .exe "
D. " .bis "C

2. The incorrect integer constant in the following options is _( C )
A. 12L
B. -10
C. 1,900
D. 123U

3. Expression____ The value of is 0. (c)
A. 3%5
B. 3/5.0
C. 3/5
D. 3<5

4. Expression( x> 0|y > 0) is equivalent to __( D )
A. !x>0||!y>0
B. !(x>0)||!(y>0)
C.!x>0&&!y>0
D. !(x>0)&&!(y>0)

5. Expression______ Does not conform to C language syntax. (D)
A. 4&&3
B.+a
C. a=b=5
D. int (3.14)

6. Execute the statement scanf ('% d% d% d', & K1, & K2, & K3); When____ Is the correct input if the variable has been correctly defined( B )
A,203040
B,20 30 40
C,20,30 40
D,20,30,40

7. Set the variable definition as int s [] = "Hello \ nworld \ n", and there are in array s____ Elements( B )
A,12
B,13
C,14
D,15

8. Let the definition of variable display be int a [2] = (1,3}, * p = & A [0] + 1; Then the value of * p is _( B )
A,2
B,3
C,4
D,&a[0]+1

9. In C language programs, variables defined inside functions are called (D)
A. Global variable
B. Whole process variable
C. External variable
D. Internal variable

10. Expression_____ Is correct for the following variable definitions( A )

```struct node{
char s[10];
int k;
}p[4];
```

A,p->k=2;
B,p[0].s=" abc" ;
C,p[0]->k=2;
D,p->s='a' ;

1. The output of the following program segments is (B)
```int *p,*q,k =1,j= 10;
p= &j;
q= &k;
p=q;
(*p)++;
printf( "%d",*q);
```

A,1
B,2
C,10
D,11

1. The following for loops, the number of cycles is _( C )
```for(x=0,y=O;(y!=123)&&(x<4);x++);
```

A. Is an infinite loop
B. The number of cycles is uncertain
C. 4 times
D. 3 times

## 2, Fill in the blanks: (8 * 3 = 24 points)

1. The basic data types in C language are: __, __, __.

2. The type specifier of ordinary integer variables in C language is __, In memory____ Byte, the data range of signed ordinary integer is______

3. The complement of integer - 35 in the computer is_____

4. Execute the following statement int a= 8; a+=a-=a*a; After that, the value of a is _.

5. There are the following statements: char a [] = {"I am a student"}; The length of the string is __, A[3]=____.

6. The difference between the symbols "a" and "a" is

7. The so-called "pointer" is "__" & " The function of the operation symbol is "_ *" The function of operation symbols is__

8. There are the following input statements: scanf (a =% D, B =% D, C =% d ", & A, & B, & C); In order to make the values of variables a, B and C 1, 3 and 2 respectively, the correct form of data input from the keyboard should be_________

1. Integer, real, character
2. int ,4,-2^31 ~ 2^31 -1
3.11011101. Complement = inverse code + 1, and the sign bit remains unchanged
4. -112
5. 14, m (pay attention to the difference between strlen and sizeof)
6."a" is a string and 'a' is a character
7. Address, * * "&" * * take the address or bitwise sum, product or pointer
8.a=1,b=3,c=2

## 3, Program blank filling (3 * 10 = 30 points)

1. Enter 10 numbers from the keyboard and find their average value.
```int main()
{
int i;
float f，sum;
for( i=1,sum=0.0;i<11;i++)
{
___________________;//scanf("%f",&f);
___________________;//sum=sum+f;
}
printf(average=%f\n",sum/10) ;
_____________________;//return 0;
}
```
1. The following procedure is to create a myfile file and save the characters input from the keyboard into the file. When the input on the keyboard is completed, close the file.
```#include<stdio.h>

main()
{
FILE *fp;
char c;
fp=___________;//open("myfile.txt","w");
do {
e = getchar( );
fputs(c,fp);
}while(c!=EOF );
_______________;//fclose(fp);
}
```
1. The function of the following program is: input the scores of thousands of students from the keyboard, count and output the highest and lowest scores, and end the input when a negative number is entered. Please fill in the blanks.
```main( )
{
float x, amax, amin;
scanf("%f",&x) ;
amax=х; amin=х;
while ( _______ )//x>0;
{
if( x>amax )
amax = x;
if(________)//x<=amin;
amin = x;
}
printf("\namax=%f\namin=%f\n" , amax , amin);
}
```

## 4, Programming questions (5 * 12 = 60 points)

1. Prompt to enter two integers a and b. If a^2 +b^2 is greater than 100, the number of more than 100 digits of a^2 +b^2 will be output. Otherwise, the sum of two digits will be output.

[for reference only]

```#include<stdio.h>
int main()
{
int a, b;
scanf("%d%d", &a, &b);
a = a * a;
b = b * b;
int sum = a + b;
if (sum > 100)
printf("%d\n", sum / 100);
else
printf("%d\n", sum);
return 0;
}
```
1. Write a program to assign the string "computer" to a character array, and then output the string at intervals from the first letter. Please complete it with a pointer.

[for reference only]

```#include<stdio.h>
#include<string.h>
int main()
{
char a[] = "computer";
char* p;
int i;
p = a;
for (i = 0; i < strlen(a); i++)
{
printf("%c", *(p + i));
}
printf("\n");
return 0;
}
```
1. The English sentences input by the keyboard are encrypted by programming. The encryption method is that when the content is an English letter, the subsequent third letter in the 26 letters replaces the letter. If it is other characters, it remains the same.

[for reference only]

```#include<stdio.h>
int main()
{
char c;
while ((c = getchar()) != '\n')
{
if ((c >= 'A' && c <= 'Z-3') || (c >= 'a' && c <= 'z-3'))
{
c = c + 3;
}
else if ((c >= 'Z-3' && c <= 'Z') || (c >= 'z-3' && c <= 'z'))
{
c = (c + 3) - 26;
}
printf("%c", c);
}
return 0;
}
```
1. Prompt to enter a string, and then add a space between each letter in the string. Please complete it with a pointer.

[for reference only]

```#include<stdio.h>
#include<string.h>
#define MAX 100
void Insert(char str[])
{
char tmp[MAX];
int i = 0;
int j = 0;
strcpy(tmp, str);
while (tmp[j] != '\0')
{
str[i++] = tmp[j];
str[i++] = ' ';
j++;
}
str[i] = '\0';
}

int main()
{
char str[MAX];
scanf("%s", str);
Insert(str);
printf("%s", str);
return 0;
}
```
1. Randomly generate 20 [10, 50] positive integers and store them in the array, and find the maximum, minimum, average and sum of all elements in the array.

[for reference only]

```#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
srand((unsigned)time(0));
int a[20];
int i = 0;
double sum = 0;
double avg = 0;
int Max = 10;
int Min = 50;

while (i < 20)
{
a[i] = 10 + rand() % 41;
if (a[i] > Max)
Max = a[i];
if (a[i] < Min)
Min = a[i];
sum += a[i];
//printf("No.%d:%d\n", i, a[i]);
i++;
}
avg = sum / 20.0;
printf("Maximum Max=%d\n minimum value Min=%d\n average value avg=%.2f\n Sum of elements sum=%.2f\n", Max, Min, avg, sum);
return 0;
}
```

Tags: C C++

Posted on Thu, 02 Sep 2021 21:51:29 -0400 by sanlove