C language review questions

First, the choice

1. TEST.C compiled generated source object files and executable files produced after the connection is (B).
A. TEST.BAK and TEST.OBJ B. TEST.OBJ and TEST.EXE
C. TEST.EXE and TEST.C D. TEST.BAK and TEST.EXE

2. The following options are legitimate real constant (C).
A. 5E2.0 B. E-3 C. 2E0 D. 1.3E

3. Bytes string "ABC" in the memory is occupied by (B).
A. 3 B. 4 C. 6 D. 8

4. In the C language, required operands must be integer operator a (D).
A. / B. ++ C. ! = D. %

5. If Type Description The following statement: char w; int x; float y; double z;, expression w * x + z - y is the result (D) type.
A. float B. char C. int D. Double

6. If x and y represents an integer, the following expression can not correctly represent the mathematical relationship | x-y | <10 is (C).
A. abs (x - y) <10 B. X - Y> -10 && X - Y <10
C. ! (X - y) <-10 ||! (Y - x)> 10 D. (X - y) * (x - y) <100

7. Known char a = '\ 103'; the statement printf ( "% 3d", a ); the output is performed (C).
A. 67 B. 'C' C. 67 D. 103

8. For the following scanf () function in the narrative, the right is (D).
A. Entry may be a real constant, such as Scanf ( "% F", 3.5 of);
B. Only format control, no entry, can be performed correctly entered, as Scanf ( "% A = D, B = D%");
C. When a real input data format of the control portion after the decimal point should be specified, such as: Scanf ( "% 4.2f", & F);
D. When input data must specify the address of a variable, such as scanf ( "% f", & f);

9. Set variables a, b and c are properly defined and assigned, then the following expression in line with the C language syntax is (A).
A. a + = 7 B. b + c = a = 7 C. a = 12.3% 4 D. a = a + 7 = c + b

10. To avoid ambiguity nesting of if-else, C language specified, else paired with (B).
A. And the outermost if B. Before its recent without if else is
C. After its recent if D. And the previous most recent} {if

11. The following program segment
int K = 10;
the while (K = 0) = K K -. 1;
the following description is correct (C).
A. while loop executes 10 times B. Loop is infinite loop
C. Loop statement is not executed a D. Loop statement is executed once

12. The main difference in the C language while and do-while loop is (A).
A. do-while loop is executed at least once unconditionally
B. The while loop control condition than do-while loop control condition strictly
C. do-while loop to allow the body from the outside
D. do-while loop of a compound statement is not

13. Where i is an integer variable, the number of times the loop is executed (B).
for (I = 2; 0 == I;) the printf ( "% D", i--);
A. Unlimited B. C. 0 times 1 D. 2 times

14. If and when a desired value is an odd number, the expression evaluates to true; when a value is even, the expression is false then the following expression is not meet the requirements (C).
A. a% 2 == 1 B. ! (a% 2 == 0) C. ! (a% 2) D. a% 2

15. About break and continue, the following statement is correct (B).
A. The break statement applies only in the body of the loop
B. continue statement applies only in the body of the loop
C. break unconditional jump statement, continue not
D. Jump range break and continue statements are not sufficiently clear, error-prone

16. If the variable is defined correctly places the next can be calculated correctly f = n! Is program segment (B).
A. for (f = 0, i = 1; i <= n; i ++) f * = i; B. for (F =. 1, I =. 1; I <= n-; I ++) * F = I;
C. for (f = 1, i = 1; i> 1; i-) f * = i; D. for (f = 1, i = 1; i> = 2; i-) f * = i;

17. In C language, a reference array element, the array subscripts data type which is not allowed to (D).
A. Integer constant B. Integer expression
C. Integer constant or integer expression D. Any type of expression

18. The following description of the right is a two-dimensional array (C).
A. int a [3] []; B. A a float (. 3) (. 4);
C. double a [] [4]; D. float a (3,4);

19. Following initialization of the array s, the error is (D).
A. char s [5] = { " abc"}; B. S char [. 5] = { 'A', 'B', 'C'};
C. char s [5] = "" ; D. char s [5] = "abcde ";

20. With the following definitions, the correct description of (B).
X char [] = { "ABCDEFG"};
char Y [] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G'};
A. Array x and the array y equivalents B. X is greater than the length of the array is an array of length y
C. Array x and the array length equal to D. X is smaller than the length of the array is the length of the array y

twenty one. If the definition int a [] [3] = {{1,2}, {3,4}} ;, the array of a total of (C) elements.
A. 4 B. 5 C. 6 D. indefinite

twenty two. Run Results The following is a program segment (C).
#include <stdio.h>
int main ()
{
int I, X [. 3] [. 3] = {. 1, 2,. 3,. 4,. 5,. 6,. 7,. 8,. 9};
for (I = 0; I <. 3; I ++)
the printf ( "% 2D", X [I] [I-2]);
return 0;
}
A. 1 5 9 B. 1 4 7 C. 3 5 7 D. 369

twenty three. Determining whether the string string s1 is greater than s2, you should use (D).
A. if (s1> s2) B. IF (strcmp (S1, S2))
C. if (strcpy (s1, s2) ) D. if (strcmp (s1, s2) > 0)

If the function does not return a value, then the type of the function (D).
A. int B. char C. float D. void

25. The following statement is not correct (B).
A. Argument can be a constant, variable or expression
B. Parameter can be a constant, variable or expression
C. Parameter may be any type
D. Parameter to be consistent with the corresponding argument type

26. C language specified, the type of function return value is determined by (D).
A. Expression Type return statement of the decision
B. Type of the calling function when the function is called is determined
C. System provisional decision when the function is called
D. In the definition of the function specified by function type being determined

27. Where not specified type stored in the local variables in the function, which implied storage type (A).
A. Auto (auto) B. Static (static)
C. External (extern) D. Register (register)

28. If instructions: int * p, n; incorrect block is (C).
A. scanf ( "% d", & n); B. Scanf ( "% D", & n-);
                        * = n-P; P = & n-;
C. p = & n; D. & = n-P;
      Scanf ( "% D", P &); Scanf ( "% D", P);

29. If the definition: int a [5]; then a first array element address may be represented as (C).
A. & a B. a + 1 C. a D. & a [1]

30. The following definitions and statements provided
int A [. 3] [2] = {. 1, 2,. 3,. 4,. 5}, P [. 3];
P [0] = A [. 1];
if
(p [0] + 1 ) array element is represented by (C).
A. a [0] [1] B. a [1] [0] C. a [1] [1] D. a [1] [2]

Second, fill in the blank

1. _ _ By the structured programming sequence, branched , cyclic _3 _ basic structure.

2. All variables are provided integral, expression (a = 2, b = 5, a ++, b ++, a + b) value _9_.

3. int is a variable, and a is the initial value of 6, the calculation expression a + = a - = a * a value of a post-60_ _.

4. Let y is an int type variables, y is a relational expression determined write _y% 2 == 1_ odd.

5. The following are the results of running the program _10, 2_.
#include <stdio.h>
int main ()
{
int X = 10, Y =. 3;
the printf ( "% D, D% \ n-", X ++, --y);
}

6. The following operating results of the program are _3,20,30,1_.
#include <stdio.h>
int main ()
{
int A = 2, B = 20 is, C = 30, D;
D ++ = A <= B - 10 ||> = 20 is || C ++;
the printf ( " D%, D%, D%, D% \ n-", A, B, C, D);
}

7. The following are the results of running the program _20_.
#include <stdio.h>
int main ()
{
int n-= 0;
n-+ = (= n-10);
the printf ( "% D \ n-", n-);
}

8. The following are the results of running the program _6_.
#include <stdio.h>
int main ()
{
int m =. 5;
IF (m ++>. 5) the printf ( "% D \ n-", m);
the else the printf ( "% D \ n-", M--);
}

9. The following are the results of running the program _c = -1_.
#include <stdio.h>
int main ()
{
int A =. 1, B = 2, C =. 3;
IF (A> B) =. 1 C;
the else
IF (A == B) C = 0;
the else C = -1;
the printf ( "% D = C", C);
}

10. The following operating results of the program are _20,0_.
#include <stdio.h>
int main ()
{
int X = 10, Y = 20 is, T = 0;
X = Y;; Y = T; IF (X == Y) = X T
the printf ( "% D, D% \ n-", X, Y);
}

11. The following operating results of the program are _2,1_.
#include <stdio.h>
int main ()
{
int X =. 1, A = 0, B = 0;
Switch (X)
{
Case 0: B ++;
Case. 1: A ++;
Case 2: A ++; B ++;
}
the printf ( "% D, D%", A, B);
}

12. The following operating results of the program are _A2C4E6_.
#include <stdio.h>
int main ()
{
char C1, C2;
int A;
C1 = '. 1';
C2 = 'A';
for (A = 0; A <. 6; A ++)
{
IF (A 2% )
the putchar (A + C1);
the else
the putchar (C2 + A);
}
}

13. The following are the results of running the program _4_.
#include <stdio.h>
int main ()
{
int I, X [10] = {2,. 3, 0,. 3, 0, 2,. 3, 2,. 1,. 3}, Y [. 4] = {0} ;
for (I = 0; I <10; I ++)
Y [X [I]] ++;
the printf ( "% D \ n-", Y [. 3]);
}

14.下面程序的运行结果是_mo_。
#include<stdio.h>
int main( )
{
char a[ ]= “morning” , t ;
int i , j = 0 ;
for( i = 1 ; i < 7 ; i++ )
if( a[j] < a[i] )
j = i ;
t = a[j] ; r
a[j] = a[7] ;g
a[7] = a[j] ;r
puts( a ) ;
}

15. The following are the results of running the program _4_.
#include <stdio.h>
int main ()
{
int. 1 = A, B;
for (B =. 1; B <= 10; B ++)
{
IF (A> =. 8)
BREAK;
IF (A == 2. 1% ). 3. 1 2
{
A + =. 5;
Continue;
}
A = A -. 3;
}
the printf ( "% D \ n-", B);
return 0;
}

16. The following program is run results _a = 1, b = 2_.
#include <stdio.h>
int main ()
{
void F (int X, Y int);
int. 1 = A, B = 2;
F (A, B);
the printf ( "% A = D, B = D% \ n-", A, B);
}
void F (int X, Y int)
{
X = 100;
Y = 200 is;
}

17. The following are the results of running the program _7 8 9_.
#include <stdio.h>
int main ()
{
int F (A int);
int = A 2, I;
for (I = 0; I <. 3; I ++)
the printf ( "% 4D", F (A)) ;
}
int F (int A)
{
int B = 0;
static int C =. 3;
B ++;
C ++;
return (A + B + C);
}

18. The following operating results of the program are _gae_.
#include <stdio.h>
int main ()
{
char A [] = "Language", B [] = "Programe";
char * P1, P2 *;
int K;
P1 = A;
P2 = B;
for (K 0 =; K <=. 7; K ++)
IF (* (K + P1) == * (P2 + K))
the printf ( "% C", * (P1 + K));
}

19. The following operating results of the program are _7,8,8_.
#include <stdio.h>
int * F (X int *, int * Y)
{
IF (. 5 * X + <* Y) X return;
the else return Y;
}
int main ()
{
int =. 7 A, B = . 8, * P, * Q, * R & lt;
P = & A; Q = & B;
R & lt = F (P, Q);
the printf ( "% D,% D,% D \ n-", * P, * Q, * R & lt);
}

20. The following program is run results _3 14 2_.
#include <stdio.h>
void Fun (A int *, int * B)
{
the printf ( "% D% D \ n-", A *, B *);
* = A 2; B = *. 4;
}
int main ()
{
int. 1 X =, Y =. 3;
Fun (& Y, X &);
the printf ( "% D% D \ n-", X, Y);
}

Third, the programming problem

1. Write a program that reads a letter, the output value of the ASCII code corresponding thereto.
#include <stdio.h>
int main ()
{
char CH;
the printf ( "Enter a character: \ n-");
Scanf ( "% C", & CH);
the printf ( "ASCII corresponding to% d", ch) ;
return 0;
}

2. Write a program that reads a capital letter, the output of the corresponding lower case letters and lower-case letters ASCII code.
#include <stdio.h>
int main ()
{
char CH;
the printf ( "Enter a capital letter: \ n-");
Scanf ( "% C", & CH);
the printf ( "lower case letters correspond to% c, ASCII code D% ", CH + 32, 32 + CH);
return 0;
}

3. Please programmed output pattern as follows:
*
***
*****
*******
#include <stdio.h>
int main ()
{
for (int I =. 1; I <=. 4; I ++)
{
for (int J =. 1; J <=. 4 - I; J ++)
{
the printf ( "");
}
for (int K =. 1; K <= 2 * I -. 1; K ++)
{
the printf ( "*");
}
the printf ( "\ n-");
}
return 0;
}

3. Write a program, calculating a main diagonal matrix and 6╳6.
main int ()
{
int A [. 6] [. 6] = {{1,2,3,4,5,6},
{7,8,9,10,11,12},
{13,14, 15, 16,17,18}
{19,20,21,22,23,24},
{25,26,27,28,29,30},
{31,32,33,34,35,36}};
SUM = 0 int;
for (int I = 0; I <. 6; I ++)
{
SUM = A + [I] [I];
}
the printf ( "% D", SUM);
return 0;
}
. 4. 10 print the value of programming the first 10 rows of Pascal's triangle.
#include <stdio.h>
int main ()
{
int A [10] [10];
int I, J;
for (I = 0; I <10; I ++)
{
A [I] [0] =. 1;
A [I] [I] =. 1;
}
for (I = 2; I <10; I ++)
{
for (J =. 1; J <I; J ++)
{
a[i][j] = a[i - 1][j - 1] + a[i - 1][j];
}
}
for (i = 0; i < 10; i++)
{
for (j = 0; j <= i; j++)
printf("%d “, a[i][j]);
printf(”\n");
}
return 0;
}

5. Write function request sum to 1 and n, by calling this function, obtained within 100 can function value is equal to n2-1 all positive integers.
#include <stdio.h>
void SUM ();
int main ()
{
SUM ();
return 0;
}
void SUM ()
{
int of Sn = 0;
int I =. 1;
the while (of Sn <= 100)
{
of Sn + I =;
the printf ( "% DN n-% =. 1-D \ n-", of Sn, I I -. 1);
IF (I * I - == of Sn. 1)
{
the printf ( "% D \ n-", of Sn);
}
i ++;
}
}
each text sentence: the slowest person, as long as he does not lose goals, but also faster pace than aimlessly wandering people.

Published 15 original articles · won praise 41 · views 6142

Guess you like

Origin blog.csdn.net/Fdog_/article/details/103845789