当前位置:网站首页>C language final review questions
C language final review questions
2022-07-28 21:00:00 【Small digital media members】
Catalog
3、 ... and 、 Reading program , Write the result
Four 、 Correct the wrong questions
5、 ... and 、 Programming questions
One 、 choice question
1. The following is not C The characteristic of language is ( C )
A.C The language is simple 、 compact B. Be able to program complex functions
C. C Language can directly operate the hardware D.C Good language portability
2. The narrative is wrong : ( D )
A. One C The source program can consist of one or more functions
B. One C The source program must contain a MAIN function
C. C The basic unit of a program is a function
D. C In the program , Note description can only be after one statement
3. One c The execution of the program is from ( A ).
A.main( ) Function to , until main( ) End of the function
B. The first function starts , Until the end of the last function
C. Start with the first statement , Until the end of the last statement
D.main( ) Function to , Until the end of the last function
4. The types of known variables are described as follows :
int k, a, b;
unsinged long w=5;
double x=1.42;
Then the following does not meet C Language grammar is ( A )
A. x%(-3)
B. w+=-2;
C. k=(a=2,b=3,a+b)
D. a+=a-=(b=4)*(a=3)
5. If the following variables are all integer , And num=sum=7; Then the expression is evaluated sum=num++,sum++,++num after sum The value of is ( B )
A.7 B.8 C.9 D.10
6. When the form of input data is :25,13,10 < enter > when , The output of the following program is ( D )
main()
{int x,y,z;
scanf(“%d%d%d”,&x,&y,&z);
printf(“x+y+z=%d\n”,x+y+z);
}
A. x+y+z=48
B. x+y+z=35
C. x+z=35
D. Uncertain value
7. sizeof(float) yes ( B ).
A. A double expression B. An integer expression
C. A function call D. An illegal expression
8. It can be expressed correctly “ When x The value of the [1,10] and [200,210] The range of is true , Otherwise it is false ” The expression of ( C )
A. (x>=1)&&(x<=10)&&(x.>=200)&&(x<=210)
B. (x>=1)││(x<=10) ││(x.>=200) ││(x<=210)
C. (x>=1) &&(x<=10) ││(x.>=200) &&(x<=210)
D. (x>=1)││(x<=10)&& (x.>=200) ││(x<=210)
analysis : according to C Priority of language operators ,&& Above ||, So we have to calculate first “ And ” Count again “ or ”, The answer for :C
9. Set description : char w; int x; float y; double z; Expression w*x+z-y The data type of the value is ( D ).
A.float B.char C.int D.double.
10. Please read the following procedure :
#include <stdio.h>
main( )
{ int a=5 , b=0 , c=0;
if (a=b+c) printf(“* * *\n”);
else printf(“$ $ $\n”); }
The above procedure (D )
A. There are syntax errors that cannot be compiled
B. It can be compiled but not directly connected
C. Output * * *
D. Output $ $ $
11. The following statement is correct ( D ).
A. The input can be a real constant ( Variable ), Such as scanf(“%f”,3.5);
B. Only format control , No entries , It can also make correct input , Such as scanf(“a=%d,b=%d”); Missing variable
C. When entering a real data , The format control part shall specify the number of digits after the decimal point , Such as scanf(“%4.2f”,&f);
D. When entering data , The address of the variable must be specified , Such as scanf(“%f”,&f);
12. C In language while and do-while The main difference between loops is . ( A )
A. do-while The body of the loop is executed unconditionally at least once
B. while Cycle control condition ratio do-while The cycle control conditions are strict
C. do-while Allow transfer from the outside to the circulation body
D. do-while Allow transfer from the outside to the circulation body
13. Known letters A Of ASCII Code is 65, The execution result of the following procedure is ( D ).
#include<stdio.h>
main()
{
char c1='A',C2='Y';
printf("%d,%d\n",c1,c2);
A.A,Y B.65,65 C.65,90 D.65,89
14. stay c In language , When referencing array elements , The data type of its array subscript is allowed to be . ( C )
A. integer constants
B. Integer expression
C. Integer constant or integer expression
D. Any type of expression
15. The data type of the operand on both sides of the logical operator ( D).
A. Can be 0 or 1
B. Can only be 0 Or not 0 Positive numbers
C. Only integer or character data
D. It can be any kind of data
16. The following correct form of function definition is . ( A )
A. double fun(int x,int y)
B. double fun(int x;int y)
C. double fun(int x,int y);
D. double fun(int x,y);
17. The following is not true if The sentence form is ( C ).
A.if(x>y&&x!=y);
B.if(x==y)x Ten =y;
C.if(x ! =y)scanf(“%d”,&x) e1se scanf(”%d,&y);
D.if(x<y){x twenty ;y twenty ;}
18. With definition :int n=0,* p=&n, q; In the following options , The correct assignment statement is ( D )
A. p=1 B. *q=2 C. *q=p D. *p=5
19. Read the following procedure
main()
{
int a=5,b=0,c=0;
if(a=b+c) printf(“***\n”);
else printf(“$$$\n”);
}
The above procedure ( A).
A. Syntax errors cannot be compiled B. It can be compiled but not connected
C. Output *** D. Output $$$
20. The standard input file of the system refers to ( A )
A. keyboard
B. Monitor
C. floppy disk
D. Hard disk
Two 、 Completion
- stay C In language , The combining direction of unary operators ( Operation direction ) yes _____ From right to left _______.
- expression 8/4*(int)2.5/(int)(1.25*3.7+2.3) The data type of the value is ( int type ( integer ) ).
- Loop statement for(;;) printf("OK \n"); and do { printf("OK\n");} while(0); Execute the cycle , The number of cycles is ______ Infinite _________ and __________1_____.
- 4. if x by int Type variable , Then execute the following statement x The value of is ( -14 )
x=7;
x+=x-=x+x;
- . The three basic structures of structured programming are : Selection structure 、 Loop structure and ____ The order structure ____________.
- Yes int a=3,b=4,c=5; Expression a||b+c&&b= =c The value of is ( 1 ).
- Set macro definition #define D (x) x/x, Then reference D(2+3) The last value is ______6_________.
- stay C In language , The storage order of two-dimensional array elements in memory is ( By line ).
- If there is a definition :double x[3][5]; be x The lower limit of the row subscript in the array is ( 0 ), The upper limit of column subscript is ( 4 ).
- C Language policy , The starting point of the executable program is ( The main function (main function ) ).
3、 ... and 、 Reading program , Write the result
1. #define PRICE 30
#include <stdio.h>
void main()
{
int num,total;
num=10;
total=num*PRICE;
printf("total=%d\n",total);
}
The output of the above program is total= 300 .
2. #include "stdio.h"
void main( )
{ int a,m=0,n=0,k=0;
scanf("%d",&a);
switch(a)
{ case 1: m++; break;
case 2:
case 3: n++; break;
case 4:
case 5: k++;
}
printf("%d,%d,%d\n",m,n,k);
}
Type... From the keyboard 1, The result of writing the program is m=1,n=0,k=0
3. The running result of the following program is :AB
#include <stdio.h>
void main()
{ char a;
a='B';
putchar('\101'); putchar(a);
}
4. When the following program runs, enter... From the keyboard 15,20, The running result is __a=15,b=20_____________.
#include "stdio.h"
void main( )
{ int a,b,t;
t = 0;
scanf("%d,%d",&a,&b);
if (a>b)
{ t = a ;a = b ;b = t ;}
printf("a=%d,b=%d\n",a,b) ;
}
5.#include "stdio.h"
void main( )
{ int i,m,p,a[10]={9,8,7,6,1,3,5,18,2,4};
m=a[0];
p=0;
for(i=1;i<10;i++)
if (a[i]<m)
{ m=a[i]; p=i;}
printf("%d,%d\n",m,p);
}
The output of the above program is m=1,p= 4
Four 、 Correct the wrong questions
1. #include <stdio.h>
void main( )
{ int x , y ;
scanf(“%d,%d”, &x, &y);
if (x>y;)
printf(“%d”,x);
else
printf(“%d”,y);
}
Change it to : #include <stdio.h>
void main( )
{ int x , y ;
scanf (“%d,%d”, &x, &y);
if (x>y)
printf(“%d”,x);
else
printf(“%d”,y);
If The semicolon goes behind
2 . #include <stdio.h>
void main()
{ char c;
c=gets( );
putchar(c);
}
Change it to :
#include <stdio.h>
void main()
{ char c;
c=getchar( );
putchar(c);
} gets Change it to getchar
analysis :gets The function is to input a line of string , End with a carriage return , And the Enter key will be filtered out , Will not be read into the string , and getchar The function is to read a character , Including the Enter key will also be read as a character
3. #include <stdio.h>
void main()
{ int max(int x,int y);
int a,b,c;
scanf("%d,%d",&a,&b);
c=max(a,b);
printf("Max is %d",c);
}
max(int x, int y)
{ int z;
z=x>y?x:y;
return(x);
}
Change it to :
#include <stdio.h>
void main()
{ int max(int x,int y);
int a,b,c;
scanf("%d,%d",&a,&b);
c=max(a,b);
printf("Max is %d",c);
}
max(int x, int y)
{ int z;
z=x>y?x:y;
return(z);
}
x Change it to z
5、 ... and 、 Programming questions
1. There is a function
Make a program , Enter a x value , Output y value .(7 branch )
#include<stdio.h>
int main()
{
int x,y;
printf(" Please enter x:");
scanf("%d",&x);
if(x<0)
y=-1;
else if(x==0)
y=0;
else
y=1;
printf("y=%d",y);
}2. Find the sum of elements with even subscripts in a one-dimensional array , Completion procedure
#include "stdio.h"
void main( )
{ int i, sum=0 ; /* Please initialize sum by 0 */
int a[]={2,3,4,5,6,7,8,9};
for(i=0; i<8; i=i+2 ) /* Please supplement the complete loop statement */
sum+=a[i]; /* Please use sum Save the sum of the elements with even subscripts in the array */
printf("sum=%d\n",sum);
}
3. Type... From the keyboard 20 Students C language achievement , Calculate the grade average , And the output .
#include<stdio.h>
int main()
{
int i;
double a[20],sum=0.0,ave;
printf(" Please enter 20 Students' grades :\n");
for(i=0;i<20;i++)
{
scanf("%lf",&a[i]);
sum+=a[i];
}
ave=sum/20.0;
printf(" The average score is :%.2lf",ave);
return 0;
}5. Program and print out all “ Narcissistic number ”, The so-called narcissus number refers to a 3 digit , The sum of the cubes of the numbers is equal to the number itself . Such as 153=13+33+53.
Programming tips : Define a variable as a loop variable , Redefine 3 Variables store each number of three digits , Split a three digit number into one digit in the loop body 、 ten 、 After 100, judge whether the value of the cyclic variable is the number of daffodils , Output if yes , Otherwise, it will not output . The basic structure of the program is :
#include "stdio.h"
void main( )
{
int a,b,c ,j ; /* Definition 4 An integer variable */
for( j=100; j<=999; j++ )
{
a= j%10 ; /* Separate out the hundreds */
b= j/10%10 ; /* Separate out the tens */
c=___j/100_____ _ __ ; /* Separate out the single digits */
if(j==a*a*a+b*b*b+c*c*c)
printf(“j=%d”,j) ;
}
printf("\n");
}
6. Find the maximum and minimum values of elements in a two-dimensional array
4 ,4,34
37,3,12,
5, 6, 5
#include<stdio.h>
int main()
{
int a[3][3]={
{4,4,34},{37,3,12},{5,6,5}};
int max=a[0][0],min=a[0][0],i,j,t;
for(i=0;i<=2;i++)
for(j=0;j<=2;j++)
{
if(a[i][j]<min)
{
t=a[i][j];
a[i][j]=min;
min=t;
}
if(a[i][j]>max)
{
t=a[i][j];
a[i][j]=max;
max=t;
}
}
printf("min=%d\nmax=%d",min,max);
}边栏推荐
- Unity typewriter teaches you three ways
- Seventeen year operation and maintenance veterans, ten thousand words long, speak through the code of excellent maintenance and low cost~
- Unity foundation 3- data persistence
- Laser slam:logo-loam --- code compilation, installation and gazebo test
- Space shooting Lesson 16: props (Part 2)
- Space shooting Lesson 11: sound and music
- Unity gets which button (toggle) is selected under togglegroup
- 什么是低代码?哪些平台适合业务人员?用来开发系统靠不靠谱?
- Establishment of flask static file service
- 《软件设计师考试》易混淆知识点
猜你喜欢

Redis 3.0 source code analysis - data structure and object SDS list Dict

Redis的三种删除策略以及逐出算法

Job CE

mysql梳理复习内容--附思维导图
Looking at SQL optimization from the whole process of one query

JS fly into JS special effect pop-up login box

What is data center? What value does the data center bring_ Light spot technology

Explain the mobile control implementation of unity in detail

Unity typewriter teaches you three ways

Explain the imported 3D model in unity
随机推荐
Unity foundation 2 editor expansion
【服务器数据恢复】HP StorageWorks系列存储RAID5两块盘故障离线的数据恢复案例
融合数据库生态:利用 EventBridge 构建 CDC 应用
System. ArgumentException: Object of type ‘System. Int64‘ cannot be converted to type ‘System.Int32‘
C# 读取 CSV文件内数据,导入DataTable后显示
GIS数据漫谈(六)— 投影坐标系统
MobileViT:挑战MobileNet端侧霸主
[complete collection of common ADB commands and their usage (from a comprehensive summary of [wake up on Sunday)]
C foundation 2-encapsulation, inheritance, polymorphism
Using viewpager to slide through pages in fragment
Explain in detail the rays and radiographic testing in unity
Why on earth is it not recommended to use select *?
Random talk on GIS data (VI) - projection coordinate system
PostgreSQL数据库删库前是不是需要把所有连接断开才能删除?
Nat experiment demonstration (Huawei switch equipment configuration)
Space shooting Lesson 10: score (painting and writing)
使用ORDER BY 排序
Beautiful blue background form input box style
The cloud native programming challenge is hot, with 510000 bonus waiting for you to challenge!
十七年运维老兵万字长文讲透优维低代码~