Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - C language problem, master it.
C language problem, master it.
Computer Programming C Language (Volume B)

Multiple choice questions (65438+ 0.5 points per question, ***24 points)

1, the following keywords are not in C language ().

A is student b, break C, select D, int.

AC is not.

2. Assuming that A and B are integer variables, the following legal expression is (a).

a、a+=a+ 1 B、a=b=b+a C、a=5++ D、a+b=2.5

3, C language, in a source program, the position of the main function (C).

A must be at the beginning and b must be at the end.

C, can be arbitrary d, must be behind the library function called by the system.

4. Int A =10 is defined; The value of expression a%3/3 is (a).

a、0 B、 1 C、2 D、 10

5. Define A and B as integer variables, and the correct way to initialize them is (b).

a、int a,b = 0; b、int a=0,b = 0; c、int a = b = 0; d、int a = 0; b = 0;

6.C has been defined as a character variable, and the correct one in the following statement is (C).

a、c = ' 97b、c = " 97c、c = 97d、c = " a

7. Pass scanf ("%d, %d ",&; I. & AMPB); To make a value of 3 and b value of 4, the correct data input form is (D).

A, 3, 4 (Enter) B, a=3, b=4 (Enter) C, a=3 (Enter) b=4 (Enter) D, 3 4 (Enter).

8. Proposition X is lowercase and can be described as (a) in C language.

a、x & gt= ' a ' & amp& ampx & lt='z' B、x & gt= ' a ' | | x & lt='z '

c、a & lt; = x & lt='z' D、x & gt='a ',x & lt='z '

9. It is defined as int a [4] = {0 0,2,4,6}, * p = &;; a[2]; Execute printf ("%d \ n ",8p-); The result of is ().

It should be printf ("%d \ n ",* p-); The answer is C.

a、0 B、2 C、4 D、6

10, with the definition: float x =10.5; Then the following statement is wrong (a)

A, x%2 B, (integer) x%2 C, x/2 D, (integer) x/2

1 1, and the number of times of loop execution in the following program segments is (d)

int i,k = 0; for(I = 0; Me! = k; i - )k++

A, infinite times b, syntax error, unable to execute c, 1 times d, 0 times.

12, the following functions are defined:

void fun(int x,int*y){……}

If the variables in the following options are correctly defined, the correct calling statement of the function fun is (c)

a、fun( 10,int *n) B、k=fun( 10, 12); Fun (10, & ampn0;; Empty fun. 10,n);

13, defined; char c; If you want to use the keyboard to input a character into the c variable, the correct statement is (d).

a、scanf("%s ",& ampc); b、scanf("%c ",c); c、getchar(c); d、c = getchar();

14, the following definition statement, the error is that (D )B also has some problems, and there may be a {

a、char a[ 10],* p = a; b、char a[]={"abcdefg ",* p = & ampa[3];

c、int a[]={ 1,2,3,4},*p=a+ 1 D、int n,a[n = 5];

15, defined as: int a[2][2]={{ 1}, {2}}; The value of element a[0][2] is (d)

A, 0 B, 1 C, 2 D, indefinite

16, the function of the following program is: after inputting data into R, calculate the circular area with radius R ... There was an error when compiling the program.

Master ()

/*Beiginning*/

{ int r; float s;

scanf("%d ",& ampr);

s = pi * r * rprintf("s=%f\n ',s);

}

The reason for the error is that there may be a single quotation mark in (printf ().

A. the writing position of the comment sentence is wrong. B the variable r storing the radius of a circle should not be defined as an integer.

C, the format descriptor in the output statement is illegal D, illegal variables are used in the assignment statement to calculate the circle area.

Read the program and give the running results. (4 points for each small question, *** 16 points)

Master ()

{int I,s = 0;

for(I = 15; I>0; I-)

{ if(I % 6 = = 0)break;

s = s+I; }

printf("%d\n ",s0;

}

Test (integer x)

{ static int j = 2;

x++; j-;

printf("x=%d,j=%d\t ",x,j);

}

Master ()

{Test (1); Test (2); }

fun(int a,int b)

{ if(a & gt; B) return to (a);

Else returns (b);

}

Master ()

{int x=3,y=8,z=6,r;

r=fun(x+y,2 * z);

printf("%d\n ",r);

}

Master ()

{int i= 10,m=0,n = 0;

Switch (I 10)

{Case 0: m++; n++;

Case1:n++;

Default: n++;+;

}

printf("%d%d\n ",m,m);

}

Fill in the blanks according to the procedure (3 points for each blank, ***30 points)

The function of the program is to calculate the number of numbers in an integer array that are not divisible by 5.

Master ()

{int a[ 10],I,count = 0;

for(I = 0; I< 10; i+=)

scanf(" _ _ _ _ _ _ _( 1)_ _ _ _ _ _ _ ",& ampa[I]);

for(I = 0; I< 10; i++)

if(_ _ _ _ _ _ _(2)_ _ _ _ _ _ _)_ _ _ _ _ _(3)_ _ _ _ _ _ _;

Printf("count=%d ",count);

}

The function of the following program is to put the numeric characters in the string S into the D array, and finally output the string in D. For example, input the string abc 123edf456gh, and output it after executing the program: 123456. Please fill in the blanks.

# contains _ _ _ (1) _ _ _ _ _ _ _

Master ()

{char s[80],d[80]; int i,j;

Obtain;

for(I = j = 0; s[i]! ='\0'; i++)

if(s[j]& gt; = ' 0 ' & amp& amps[j]& lt; ='9')

{ d[j]= s[I]; _____(2)____; }

d[j]= ' \ 0 ';

___(3)____;

}

The function of the program is to sort the integer array a containing n elements from small to large by bubbling method.

Void sorting (_ _ _ _ _ _ (1) _ _ _ _ _ _)

{int i,j,temp

for(I = 0; I<n-1; i++)

for(j = 1; j & ltn-I; ____(2)____)

if(a[j- 1]>a[j])

{ temp = a[j]; a[j]= _ _ _ _ _ _(3)_ _ _ _ _ _ _ _; _ _ _ _ _ _ _ _(4)_ _ _ _ _ _ _ _ = temp; }

}

Master ()

{int a[ 10],I;

for(I = 0; I< 10; i++)

scanf("%d ",& ampa[I]);

Sorting (a,10);

for(I = 0; I< 10; i++)

printf("%d ",a[I]);

}

Programming (***30 points)

Write a program to calculate: s =1+1/2+1/3+...+1/00.

Make up a function to judge whether m is a prime number. Call this function with the main function and output prime numbers between 3~ 100.