Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Why is 435 not an integer constant?
Why is 435 not an integer constant?
Neusoft

C language programming problem set

C programming problem set

Chapter 1 Basic knowledge of C language

1. 1 fill in the blanks

1. To convert a source program written in a high-level language into an object program, you need to use the.

A) editing program b) driver c) diagnostic program d) compiler

2. If there are explanatory statements: int a, b, c, * d = &;; c; , you can correctly read in three integers from the keyboard and assign them to variables A, B and C respectively.

A) scanf("%d%d%d ",& i, & b, d); B) scanf("%d%d%d ",& i, & ampb & amp;; d);

C) scanf("%d%d%d ",a,b,d); D) scanf("%d%d%d ",a,b,* d);

3. The legal user identifier in the following options is _ _ _ _ _ _.

A) long B) _2Test C) 3Dmax D) A.dat

4. Let A and B be double constants, a=5.5 and b=2.5, then the value of the expression (int)a+b/b is _ _ _ _ _.

a)6.500000 B)6 C)5.500000D)6.000000

5.I, j and k are called int variables. If you enter them from the keyboard: 1, 2, 3, then the value of I is 1, the value of J is 2, and the value of K is 3. The correct input statement in the following options is _ _ _ _ _.

A) scanf("%2d%2d%2d ",&me&&; k);

B)scanf("% d% d% d ",&me&&; k);

C) scanf("%d, %d, %d ",&me&&; k);

D) scanf("i=%d, j=%d, k=%d ",&me&&; k);

6. The execution of C language programs always starts with ().

A) the first executable statement in the program

The first function in the program

C) main functions

D) Include the first function in the file.

7. The following statement is true ()

A) C programming, regardless of uppercase and lowercase letters.

B) When writing a C program, only one statement can be written in one line.

C) When writing a C program, you can write several lines in a statement.

D) When writing a C program, each line must have a line number.

8. If there is a statement: int a;; Floating b; , the following input statement is correct ()

A) scanf("%f%f ",& i, & b);

B) scanf("%f%d ",& 1, & b);

C) scanf("%d, %f ",& 1, & b);

D) scanf("%6.2f%6.2f ",& i, & b);

9. The output of the following program is ()

Master ()

{ int x= 1 1,y = 1 1;

printf("%d%d\\n ",x -,-y);

}

A) 1 1, 1 1 B) 10, 10 C) 10, 1 1 D) 1 1

10. When the following program segment is executed to assign values to X and Y, it is () that cannot be used as a data separator.

int x,y;

scanf("%d%d ",& ampx & amp; y);

A) space B) Tab key c) carriage return d) comma

1 1. To assign 25 and 2.5 to A and B respectively, the correct input method is.

int a;

Floating b;

Scanf("a=%d, b=%f ",& i, & b);

A) 25□2.5

25,2.5

C) a=25,b=5.5

D) a=25□b=2.5

12. the ASCII code of English lowercase letter d is 100, and the ASCII code of English uppercase letter d is

A) 50 B) 66 C) 52 D) 68

13. The error in the following definition statement is ().

A)int a=3,b = 5; B) floating point x1; x2;

C)char c 1,c2,C3; D) bis y3, y4;

14. If integers 4 and 5 are assigned to integer variables A and B, for the statement scanf ("%d% d ",&; I. & AMPB); When inputting data from the keyboard, the correct data input format is ().

a)4.5 B)4.5 C)4:5D)4 # 5

15. If the values of integer variables A and B are 6 and 8, respectively, the following statement prints f("a=%d, b=%d ",A, B); The output of is ().

A)6,8 B)6 8 C)a=6 b=8 D)a=6,b=8

Character constant in 16. C language is a character enclosed by ().

A) double quotation marks b) single quotation marks c) \...\ d) *...*

Escape character in 17. C language is used for ().

A) carriage return, line feed, b) horizontal tab.

C) Jump vertically to the next row of the column; D) Move the cursor to the beginning of the line.

18. If defined: int a=8, b=5, c; Execute statement c = a/b+0.4; After that, the value of c is

A) 1.4 B) 1 C) 2.0 D) 2

19. If the constant 327 is to be stored in the variable A, what types can A be defined as? (multiple choice)

A.int B. char

C. long D. floating

20. Which of the following expressions has a value of 4? (single choice)

A. 1 1/3

C.(float) 1 1/3d .(int)( 1 1.0/3+0.5)

# include & ltstdio.h & gt

# include & ltmath.h & gt

Master ()

{int a= 1,b=4,c = 2;

float x=5.5,y=9.0,z;

z =(a+b)/c+sqrt((double)y)* 1.2/c+x;

printf("%f\n ",z);

}

a)9.800000 B)9.300000 C)8.500000D)8.00000。

2 1.main()

{int x = 10,y = 3;

printf("%d\n ",y = x/y);

}

A).0 B). 1 C).3 D)。 Uncertain value

main()

{ int a;

printf(" % d \ n "; (a=3*5,a*4,a+5));

}

a). 65 B). 20 C). 15D). 10

23. It is known that the ASCII code of lowercase letter A is 97 and that of uppercase letter A is 65. The following procedure

Master ()

{unsigned int a=32, b = 66.

printf("%c\n ",a+b);

}

The results are as follows:

A).66 B).98 C)。 b D)。 B

24. The following definitions are provided

int x= 10,y=3,z;

statement

printf("%d\n ",z=(x%y,x/y));

The output of is

A). 1 B).0 C).4 D).3

25.# Define SQR(X) X*X

Master ()

{

int a= 10,k=2,m = 1;

a/= SQR(k+m)/SQR(k+m);

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

}

A). 10 B). 1 C).9 D).0

26.#define MAX(x,y) (x)>(y)? (x):(y)

Master ()

{ int a= 1,b=2,c=3,d=2,t;

t=MAX(a+b,c+d)* 100;

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

}

The running result of is:

A).500 B).5 C).3 D).300

27. The output of the following program is

Master ()

{

int x= 10,y = 10;

printf("%d %d\n ",x -,-y);

}

a). 10 10 B). 9 9 C). 0 10D). 10 9 .

28. Statement: printf ("%d ",(a = 2)&; & amp(b =-2)); The output of is

a)。 No output b). The result is uncertain c). - 1 D). 1

33. When the value of c is not 0, the value of c can be correctly assigned to variables A and B..

a)。 c = b = a;

b)。 (a=c)||(b=c)

c)。 (a = c)amp; & amp(b=c)

d)。 a=c=b

29. The logical expression that can correctly indicate that both A and B are positive or negative is

a)。 (a & gt= 0 | | b & gt= 0)& amp; & amp(a & lt0 | | b & lt0) B)。 (a & gt= 0 & amp& ampb & gt= 0)& amp; & amp(a & lt0 & amp& ampb & lt0)

c)。 (a+b & gt; 0)& amp; & amp(a+b & lt; =0) D)。 a * b & gt0

30. The following legal transfer statements are

a)x+y = 2002; B) ch= "green"; c)x =(a+b)++; d)x = y = 03 16;

3 1. Which of the following expressions has a value of 4? (single choice)

A. 1 1/3

C.(float) 1 1/3d .(int)( 1 1.0/3+0.5)

32. it is known that a is an integer variable, so it is the same as expression a! =0 What expressions have the same true and false values? (multiple choice)

A.a>0 | | a< Bachelor of Arts

C.! a= =0 D! a

33. The following is an illegal assignment statement.

A) n=(i=2,++ I); b)j++; c)++(I+ 1); d)x = j & gt; 0;

34. If there are the following procedures:

Master ()

{int k=2,i=2,m;

m =(k+= I * = k); printf("%d,%d\n ",m,I);

}

The output after execution is _ _ _ _ _.

a)8.6 B)8.3 C)6.4D)7.4

35. Existing definitions: int x=3, y=4, z = 5;; , expression! (x+y)+z- 1。 The value of&+z/2 is _ _ _ _ _.

A) 6 B) 0 C) 2 D) 1

36. The output of the following program is

Master ()

{

int a = 3;

printf("%d\n ",(a+= a-= a * a));

}

a)-6b) 12 C)0d)- 12

37. Let A, B, C, D, M and N all be variables of type int, and a=5, b=6, c=7, d=8, m=2 and n=2, then the logical expression (M = A >;; B) after the operation with amp& amp(n = c>d), the value of n is

A) 0 B) 1 C)2 D) 3

38. Assume that w, x, y, z and m are all int variables, and there are the following program segments:

w = 1; x = 2; y = 3; z = 4;

m =(w & lt; x)? w:x;

m =(m & lt; y)? Male: y;

m =(m & lt; z)? m:z;

So after the program runs, the value of m is

A) 4 B) 3 C) 2 D) 1

1.2 Fill in the blanks

1. The output of the following program segment is.

int k = 10;

float a=3.5,b=6.7,c;

c = a+k % 3 *(int)(a+b)% 2/4;

2. The value of expression 5%(-3) is, and the value of expression -5%(-3) is.

3. Inta = 5 is known; Then execute a+= a-= a * a; Statement, the value of is.

4. The running result of the following program is x=, y=.

Master ()

{ float x = 4.9int y;

y =(int)x;

printf ("x=%f,y=%d ",x,y); }

5. if the definition is: int a=8, b=5, c; Execute statement c = a/b+0.4; After that, the value of c is.

6. The output of the following program is.

Master ()

{ int a=5,b=4,c=6,d;

printf("%d\n ",d = a & gtb? (a & gtc? A: C): (B);

}

7. The output of the following program is.

Master ()

{ int a=4,b=5,c=0,d;

d=! a & amp& amp! b||! c;

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

}

8. Write the following values when A = 3, B = 4 and C = 5.

The value of a<b is _ _, a.

The value of a==c is _ _, a! The value of =c is _ _,

The value of a & amp& ampb; amp is _ _! The value of a & amp b is _ _,

The value of a||c is _ _! The value of a||c is _ _,

a+b & gt; The value of c&& = = c is _ _.

9. The value of integer variable A is 5, and the expression A/= A+A; The value.

10. It is known that a=3, B = 4, C = 5, and the logical expression A || B+C&; The value of&b-c

1 1. Known a=3, B = 4, C = 5, logical expression! (a>b) amp& amp & The value of c|| 1

1.3 programming problems

1. Programming: Display a sentence "Hello Neusoft!" On the screen. .

2. Write a program to output the following patterns on the screen:

*

***

*****

*******

3. Given a circle with a radius of 5.6, find its diameter, perimeter and area and output it.

4. Input the radius of the circle from the keyboard, find its diameter, perimeter and area and output.

5. Write a program to find the volume of any circle.

6. Find two real roots of any quadratic equation.

Chapter II Design of Sequential Program Structure

2. 1 Fill in the blanks

1. The computer language provides three basic control structures, namely. People advocate using these three structures to write programs, and call such programming.

2.2 Programming problems

1. Enter five integers from the keyboard, sum and average them and output them.

2. Write a program. Two integers input from the keyboard are stored in variables C 1 and C2 respectively, and their values need to be exchanged through the program.

Chapter III Branch Planning

3. 1 Fill in the blanks

1. It can correctly express "When the value of x is in; C.int A[][3]; D.int A[ 10];

16. The following character array str is defined and assigned correctly ().

a . char str[ 10]; str =;

b . char str[]=;

c . char str[ 10]; strcpy(str," abcdefghijklmnop ");

d . char str[ 10]=;

17. charstr [10] = "China \ 0" being executed; The result of strlen(str) is ().

A.5 B.6 C.7 D.9

18. executing charstr [10] = "ch \ Nina \ 0"; The result of strlen(str) is ().

A.5 B.6 C.7 D.9

19. You should use the () function when accepting a string with spaces entered by the user.

a . scanf()b . gets()c . getchar()d . getc()

20. When outputting a string with spaces, you should use the () function.

a . printf()b . puts()c . putchar()d . putc()

5.2 Fill in the blanks

1. If there is a definition statement char c [10] = "hello ",s [] =" world "; , the length of character array c is, the length of character array c is, the length of string "hello" is, and the length of string "world" is _.

2. The string "Hello, world! The length of "is, if there is a statement char s [] =" hello, world! " , the size of the array s is.

3. The result of input language programming is.

# include & ltstdio.h & gt

Master ()

{

String [30];

scanf("%s ",str);

printf("str=%s\n ",str);

}

4. The result of input language programming is.

# include & ltstdio.h & gt

Master ()

{

String [30];

gets(str);

printf("str=%s\n ",str);

}

5. The results of the following process are as follows.

# include & ltstdio.h & gt

Master ()

{

int a[]=,I,j,s = 0;

j = 0;

for(I = 3; I & gt=0; I-)

{

s = s+a[I]* j;

j = j * 10;

}

printf("s=%d\n ",s);

}

6. The results of the following process are as follows.

# include & ltstdio.h & gt

Master ()

{

char str[]=;

int I;

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

if (str[i]>= ' 0 ' & amp& ampstr[I]& lt; ='9')

printf("%c ",str[I]);

printf(" \ n ");

}

5.3 Programming problems

1. Enter five integers from the keyboard, save them in array A, and output them in the positive order first, and then in the reverse order.

2. Enter 6 integers from the keyboard and save them in the array, calculate the largest element, and exchange this largest element with the last element of the array. Finally, output the entire array.

3. Input 8 integers from the keyboard and save them in the array, and output the array after sorting them from large to small by selection method.

4. Programming realization: input 10 characters from the keyboard and store them in the character-based one-dimensional array str, and then input another character ch from the keyboard to delete the first ch character appearing in the str. Output the array str after deleting ch to the screen.

5. Write a program to realize: exchange two string arrays.

6. The program calculates the sum of two 3×4 (3 rows and 4 columns) matrices, and then outputs them (the values of matrix elements are input from the keyboard).

7. Define a two-dimensional integer array with 4 rows and 5 columns, assign values to it, and then select a minimum number and its subscript value from the array (the subscript values of both rows and columns should be recorded).