Test Questions and Answers made two days ago

Source: Internet
Author: User

One blank question (20 points)

1. The value of C language expression 5> 2> 7> 8 is ().

2. After the following statement is executed, the value of variable A is (), value of D is (), and value of E is ().

A = 6; B = ++ A; C = -- A; D = A ++; E = --;

3. The output result of the following program section is ().

Char A = 111; A = a ^ 00; printf ("% d % O/N", a, );

4. array a is defined as follows. All elements in array a are () in the memory order ().

Char A [3];

5. If the following macro definition is set, the value of a is () after the value assignment statement A = pp + 20 (A is an int variable) is executed ().

# Define PR 8

# Define pp Pr * 40

6. When defining the struct type, the keyword () should be used. When defining the enumeration type, the keyword () should be used ().

7. c files can be divided into () files and () files.

8. If char a [3] = "as"; then * A = (), * (a + 2) = ().

Second, right or wrong judgment (5 points, "√" for the right, and "×" for the wrong one ")

1 .. ()

2. The value of expression 1/4 + 2.75 is 3. ()

3. There is only one struct type. ()

4. If the function has no return value, it must be an invisible parameter. ()

5. The C language can only process text files and binary files. ()

Second, right or wrong judgment (10 points, 1 point per question. "√" And "× ")

1. In Turbo C, the actual data occupies 4 bytes in the memory. ()

2. The function called by the main function can only be a library function. ()

3. You can perform auto-increment or auto-subtraction operations on integer variables, but not on constants or expressions. ()

4. The combination direction of Arithmetic Operators and value assignment operators is from left to right. ()

5. Any function defined after the main function must be declared in main. ()

6. Only one return statement is allowed in a function. ()

7. Any array must be defined before use. ()

8. The meaning of * P in int * P; is the same as that in the printf ("% d", * P); statement. ()

9. When defining enumeration, enumeration constants can be identifiers or numbers. ()

10. files opened in the fopen ("file1", "R +") mode can be modified. ()

Three-choice questions (20 points, 2 points per question)

1. A and B are integer variables, neither of which is 0. In the following relational expressions, constant is ().

(A) a * B/a * B = 1 (B) a/B * B/a = 1

(C) A/B * B + A % B = a (d) a/B * B =

2. The basic unit of the C language source program is ().

(A) Process (B) function (c) subroutine (d) identifier

3. The following function call statement contains () real parameters.

Func (E1, E2), (E3, E4, E5 ));

(A) 2 (B) 3 (c) 5 (d) syntax error

4. The following for loop ().

For (x = 0, y = 0; (y! = 123) & (x <4); X ++ );

(A) Three executions (B) four executions

(C) an indefinite number of cycles (d) is an infinite loop.

5. The output result of the following program is ().

# Define N 2

# Define m n + 2

# Define cube (x) (x * X)

# Include "stdio. H"

Main ()

{Int I = m;

I = cube (I );

Printf ("% d/N", I );

}

(A) 17 (B) 64 (c) 125 (d) 53

6. The output result of the following program is ().

Main ()

{Int I = 010, j = 10, * Pi, * PJ;

Pi = & I; PJ = & J;

Printf ("% d. % d/N", * Pi, * PJ );

}

(A) 10, 10 (B) 8, 10 (c) 010,10 (d) 8, 8

7. In the following sections, the values of the enumerated variables c1 and c2 are () and () in sequence (),().

Enum color {red, yellow, blue = 4, green, white} C1, C2;

C1 = yellow; C2 = white;

Printf ("% d, % d/N", C1, C2 );

(A) 1 (B) 3 (c) 5 (d) 6

8. To open an existing non-empty file "file" for modification, select the correct statement ().

(A) fp = fopen ("file", "R"); (B) fp = fopen ("file", "W ");

(C) fp = fopen ("file", "R +"); (d) fp = fopen ("file", "W + ");

9. The output result of the following program is ().

Main ()

{Char S1 [20] = "ABC", S2 [20] = "123 ";

If (strcmp (S1, S2)> 0) printf ("% s/n", S1 ));

Else printf ("% s/n", S2 );

}

(A) ABC (B) 123 (c) ABC123 (d) 123abc

10. The description of employee records is as follows. Set "Birthday" in variable W to "October 25, 1993". The correct Assignment Method for "Birthday" is ().

Struct worker

{Int no; char name [20]; char sex;

Struct {int day; int month; int year;} birth;

};

Struct worker W;

(A) Day = 25; month = 10; year = 1993;

(B) W. Birth. Day = 25; W. Birth. month = 10; W. Birth. Year = 1993;

(C) W. Day = 25; W. month = 10; W. Year = 1993;

(D) birth. Day = 25; Birth. month = 10; Birth. Year = 1993;

4. Write the running results of the following programs (25 points, 5 points per question)

1. Main ()

{Int I, J;

I = 16; j = (I ++) + I; printf ("% d/N", J );

I = 15; printf ("% d/T % d/N", ++ I, I );

}

2. # include "stdio. H"

Main ()

{Int I;

For (I = 1; I + 1; I ++)

{If (I> 4)

{Printf ("% d/N", I ++ );

Break;

}

Printf ("% d/N", I ++ );

}

}

3. # include "stdio. H"

Main ()

{Int I, j, a [] = {0, 2, 8, 4, 5 };

Printf ("/N ");

For (I = 1; I <= 5; I ++)

{J = 5-i;

Printf ("% 2D", a [J]);

}

}

4. # include "stdio. H"

Main ()

{Char string1 [] = {"abcdefghij"}, string2 [10];

S (string1, string2, 5 );

Printf ("% s/n", string2 );

}

S (p, q, m)

Char * P. * q;

Int m;

{Int n = 0;

While (n <s-1)

{N ++;

P ++;

}

While (* P! = '/0 ')

{* Q = * P;

P ++;

Q ++;

}

* Q = '/0 ';

}

5. Main ()

{Int y;

FAC (5, & Y );

Printf ("y = % d/N", y );

}

FAC (int n, int * t)

{Int S;

If (n = 1) | (n = 0) * t = 2;

Else {FAC (n-1, & S); t = n * s ;}

}

5. Read the following program and enter the appropriate content to complete the program (25 points, 2 points for each blank space)

1. Try to find the "full number" within 1000 ". (Note: If a number is equal to the sum of its factors (the factor includes 1, not the number itself), the number is called "full number ". For example, if 6 is 1, 2, 3, and 6 is 1 + 2 + 3, 6 is a "full number ".)

Main ()

{

Int I, a, m;

For (I = 1; I <1000; I ++)

{

For (m = 0, A = L; A <= I/2; A ++)

If (! (I % A) (1 );

If (2) printf ("% 4D", I );

}

}

2. Sort the input 10 characters by the "bubble" method and then output them in ascending order.

# Define N 10

Char STR [N];

Main ()

{

Int I, flag;

For (I = 0; I <10; I ++)

Scanf ("% C", & STR [I]);

Sort (_ (1 )__);

For (I = 0; I <n; I ++)

Printf ("% C", STR [I]);

Printf ("/N ");

}

Sort (STR)

Char STR [N];

{Int I, J;

Char T;

For (j = 1; j <n; j ++)

For (I = 0; I <n-J; I ++)

If (STR [I]> (2 ))

{T = STR [I];

______ (3 )______;

______ (4 )______;

}

}

3. copy the information in one disk file to another.

# Include "stdio. H"

Main ()

{(1) * in, * out;

Char CH, infile [10], OUTFILE [10];

Printf ("Enter the infile name:/N ");

Scanf ("% s", infile );

Printf ("Enter the OUTFILE name:/N ");

Scanf ("% s", OUTFILE );

If (in = fopen (infile, "R") = NULL)

{Printf ("cannot open input file./N ");

Exit (0 );

}

If (out = fopen (OUTFILE, "W") = NULL)

{Printf ("cannot open output file./N ");

Exit (0 );

}

While (! Feof (in ))

Fputc (2), OUT );

(3 );

(4 );

}

4. Use a pointer as a function parameter and compile the program to find the largest and smallest element values in a one-dimensional array.

# Define N 10

Main ()

{

Void maxmin (INT arr [], int * pt1, int * pt2, int N );

Int array [N] = {,-}, * P1, * P2, A, B;

P1 = & A; P2 = & B;

Maxmin (array, P1, P2, N );

Printf ("max = % d, min = % d", a, B );

}

Void maxmin (INT arr [], int * pt1, int * pt2, int N)

{

Int I;

* Pt1 = * pt2 = arr [0];

For (I = 1; I <n; I ++)

{

If (ARR [I]> * pt1) (1 );

If (ARR [I] <* pt2) (2 );

}

}
 
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.