Computer c programming questions and answers

Computer Level 2 C Mock Questions and Answers

Computer Level 2 C Mock Questions and Answers 2017

1.1 Single Choice Questions

1.Of the following variable names, the illegal one is (C).


2.Of the following constants, the hexadecimal int constant is (A).



3.Of the following constants, the one that is not a character constant is (B).

A. ‘\n’ B. “y”

C. ‘x’ D. ‘\7’

4. The following variable a is defined within the function body, and the storage class of a is (D).


A. Register class B. External class

C. Static class D. Automatic class

5. The following description of the storage class of a variable is incorrect (C).

A. Any variable defined has a defined storage class

B. The storage class of a variable determines the scope and lifetime of the variable

C. A variable defined without a storage class descriptor is always an auto class

D. The storage class descriptor for both internal static class variables and external static class variables is static

6. .The following description of variable data types is wrong (A).

A. The int data type can be omitted when defining a variable

B. The data type of a variable determines the number of bytes of memory that the variable occupies

C. The data type of a variable can be forced

D. There are higher and lower data types for variables

7. The suffix for a long double-precision floating-point constant is (C).



8. The following operators cannot be used for floating point operations (D).



9.The following operators have the highest precedence (A).

A.*(binomial) B.||

C.>> D.%=

10.Of the following operators, the one with the lowest precedence is (B).

A.==B.? :


11.Known as: inta(3); the following expression is incorrect (C).



12.It is known that: intb(5); the following expression is correct (D).

A.b=”a” B.++(b1)

C.b%2.5D.b=3, b+1, b+2


13.The following ‘s description of type conversion is wrong (C).

A. The type conversion operator is (<type>)

B. The type conversion operator is a unary operator

C. The type conversion operator is usually used in value-preserving conversions

D. The type conversion operator acts on the left-hand side of the expression

1.1 Judgment Questions

× 1. Both the C++ language and the C are both object-oriented programming languages.

√2. Object-oriented methods are encapsulated, inherited, and polymorphic.

√3. C is a subset of C++. C++ inherits from C.


×4.C++ language programs are function strings like C language programs.

×5.C++ language supports encapsulation and inheritance and does not support polymorphism.

√6. The C++ language is much stricter than C in terms of data types.

√7. The C++ language has made an improvement in the C language, making it easier to program.

√8. C++ source programs may have error messages at compile time, but not at link time.

√9. Compiling a C++ source program with a Warning error can also generate an executable file.

√10.The implementation of a C++ language program also goes through 3 steps: editing, compiling linking and running.

From the modification of the program in Question 1.5, Question 1, summarize what should be noted about programming.

A: C++ programs should include iostraem.h, and the main() function should be preceded by the type specifier void.

Do variables appearing in a C++ program have to be stated before they are used? Do all descriptions of variables within a function have to be placed at the beginning of the function body?

A: Variables that appear in a C++ program must be specified before they are used. Variables that appear in a C++ program must be specified before they are used, but they do not have to be specified at the beginning of the function body.

What should be noted when outputting string constants using cout and the insertion character (<<)?

A: You can output one string constant or multiple string constants. Use the insertion character (<<) once for each string constant output.

Can you use a variable that has been defined in a program but has not been assigned a value or has a default value?

A: It cannot be used. Because its value is uncertain.

5. A program compiles and generates an executable file, and then runs it and gets an output, is the result always correct?

A: Not necessarily correct. There may be algorithmic errors.


Seek answers to C language practice questions

2. Fill in the blanks

1.A ___ variable ___ is a quantity whose value can change during the running of a program.

2.C is a ____ distinguishable ___ (distinguishable/non-distinguishable) alphabetic case language.Password and password are two ___ different ___ (same/different) identifiers in C. Horizontal tab _______, ‘\”‘_______ double-quote character “””_______

4. The types of the following constants are:

1.5E12 ___floating-point type _______. 1288L ___ integer ____, ‘a’___ character ___, “a”___ string ___

08 ___ shaping ___, ‘\007’___ integer ___

5. The C language source program must have and have only one ___ main function ___ function, and program execution starts with it.

6. Structured program design has three basic structures: ___sequential ___, ___selective ___, and ___loop ___.

3. Judgment Questions

1. C is not a structured programming language. (Wrong)

2. C is a weakly typed language, and for the convenience of type conversion, it is very lax about types and does not do type checking in many cases. (Right)

3. C has the characteristics of a high-level language as well as some of the characteristics of a low-level language. (Right)

4. A C source program can consist of multiple files, each of which can have a main function main(). (Wrong)

5. C programs begin execution with the main() function, so the main function main() must be placed at the beginning of the program. (Wrong)

6. The number of characters in a named identifier must not exceed six. (Wrong)

7. For the same data type, the larger the value of a variable, the more bytes of memory it occupies. (Wrong)

8. When defining a variable, you must indicate the type of the variable, but you do not necessarily have to initialize the variable. (Right)

9. “” means an empty string constant and ” means an empty character constant. (Right)

10. Multiple numeric data types occur in an expression, type conversion is performed before arithmetic operations. (Right)

11. Floating-point numbers cannot be incremented or decremented; only integers can be incremented or decremented. (Wrong)

12. If a and b are known to be integer variables, the expression a=3,2+4,b=6,7+8 is a comma expression. (Right)


1.Write the value of the following expression






what is the final result of i, j What is it? i=5, j=4

(3) inta=3,b,c;


c=(+++a)+(+++a)+(+++a);What is the final result of a, b, c? a=9,b=9,c=25

2. Are the following expressions correct ? If correct, what is the value of the expression ?



Write a program that outputs the following message on the screen:

============= ======



#include “stdio.h”



printf(“= Iamastudent.=”);