194道C语言复习练习题及答案

合集下载

(完整版)C语言题库(带详解答案)

(完整版)C语言题库(带详解答案)

(完整版)C语⾔题库(带详解答案)⼀单项选择题1.(A)是构成C语⾔程序的基本单位。

A、函数B、过程C、⼦程序D、⼦例程2.C语⾔程序从 C开始执⾏。

A) 程序中第⼀条可执⾏语句 B) 程序中第⼀个函数C) 程序中的main函数 D) 包含⽂件中的第⼀个函数3、以下说法中正确的是(C)。

A、C语⾔程序总是从第⼀个定义的函数开始执⾏B、在C语⾔程序中,要调⽤的函数必须在main( )函数中定义C、C语⾔程序总是从main( )函数开始执⾏D、C语⾔程序中的main( )函数必须放在程序的开始部分4.下列关于C语⾔的说法错误的是(B)。

A) C程序的⼯作过程是编辑、编译、连接、运⾏B) C语⾔不区分⼤⼩写。

C) C程序的三种基本结构是顺序、选择、循环D) C程序从main函数开始执⾏5.下列正确的标识符是(C)。

A.-a1B.a[i]C.a2_iD.int t5~8题为相同类型题考点:标识符的命名规则(1)只能由字母、数字、下划线构成(2)数字不能作为标识符的开头(3)关键字不能作为标识符选项A中的“-” ,选项B中“[”与“]”不满⾜(1);选项D中的int为关键字,不满⾜(3)6.下列C语⾔⽤户标识符中合法的是( B)。

A)3ax B)x C)case D)-e2 E)union选项A中的标识符以数字开头不满⾜(2);选项C,E均为为关键字,不满⾜(3);选项D中的“-”不满⾜(1);7.下列四组选项中,正确的C语⾔标识符是(C)。

A) %x B) a+b C) a123 D) 123选项A中的“%” ,选项B中“+”不满⾜(1);选项D中的标识符以数字开头不满⾜(2)8、下列四组字符串中都可以⽤作C语⾔程序中的标识符的是(A)。

A、print _3d db8 aBcB、I\am one_half start$it 3paiC、str_1 Cpp pow whileD、Pxq My->book line# His.age选项B中的“\”,”$” ,选项D中“>”,”#”,”.”,”-”不满⾜(1);选项C中的while 为关键字,不满⾜(3)9.C语⾔中的简单数据类型包括(D)。

c语言基础试题库及答案

c语言基础试题库及答案

c语言基础试题库及答案一、选择题1. C语言中,用于定义一个结构体的关键字是:A. structB. unionC. enumD. typedef答案:A2. 下列哪个选项不是C语言的标准数据类型?A. intB. floatC. charD. string答案:D3. 在C语言中,用于实现循环的关键字是:A. whileB. forC. ifD. switch答案:A、B4. C语言中,用于定义函数的关键字是:A. functionB. defC. voidD. int答案:C5. 下列哪个选项是C语言中的合法变量名?A. 2variableB. variable2C. variable_2D. int答案:B、C二、填空题1. C语言中,________关键字用于定义一个数组。

答案:int2. 在C语言中,________关键字用于定义一个指针。

答案:*3. C语言中,________关键字用于定义一个函数。

答案:int4. 在C语言中,________运算符用于求两个数的和。

答案:+5. C语言中,________运算符用于判断两个数是否相等。

答案:==三、简答题1. 请简述C语言中函数的定义和调用过程。

答案:函数定义包括函数的返回类型、函数名、参数列表和函数体。

函数调用则是通过函数名和参数列表来调用已定义的函数。

2. 解释C语言中指针的概念及其用途。

答案:指针是一种变量,它存储了另一个变量的内存地址。

指针常用于动态内存分配、数组处理和函数参数传递。

四、编程题1. 编写一个C语言程序,计算并输出100以内所有偶数的和。

答案:```c#include <stdio.h>int main() {int sum = 0;for(int i = 1; i <= 100; i++) {if(i % 2 == 0) {sum += i;}}printf("Sum of even numbers from 1 to 100 is: %d", sum);return 0;}```2. 编写一个C语言函数,用于交换两个整数变量的值。

C语言全部章节习题集及答案

C语言全部章节习题集及答案

《C语言程序设计》1 C语言概述一、单项选择题第一章 C语言概述一、选择题:1、一个C程序的执行是从( A )。

A本程序的main函数开始,到main函数结束B本程序文件的第一个函数开始,到本程序文件的最后一个函数结束C本程序的main函数开始,到本程序文件的最后一个函数结束D本程序文件的第一个函数开始,到本程序main函数结束2、在 C 语言中,每个语句必须以( D )结束。

A. 回车符B. 冒号C. 逗号D. 分号3、C 语言规定:在一个源程序中,main函数的位置( C )。

A. 必须在最开始B. 必须在系统调用的库函数的后面C. 可以任意D. 必须在最后4、一个C 语言程序是由( B )。

A. 一个主程序和若干子程序组成B. 函数组成C. 若干过程组成D. 若干子程序组成5、下列说法中错误的是( D )。

A. 主函数可以分为两个部分:主函数说明部分和主函数体B. 主函数可以调用任何非主函数的其他函数C. 任何非主函数可以调用其他任何非主函数D. 程序可以从任何非主函数开始执行6、用 C 语言编写的源文件经过编译,若没有产生编译错误,则系统将( C )。

A. 生成可执行目标文件B. 生成目标文件C. 输出运行结果D. 自动保存源文件二、填空题:1、C 语言只有32个关键字和9种控制语句。

2、每个源程序有且只有一个 main 函数,系统总是从该函数开始执行C语言程序。

3、C 语言程序的注释可以出现在程序中的任何地方,它总是以 \* 符号作为开始标记,以 */ 符号作为结束标记。

4、C 语言中,输入操作是由库函数scanf完成的,输出操作是由库函数printf完成的。

5、系统默认的 C 语言源程序文件的扩展名是 .c,经过编译后生成的目标文件的扩展名是 .obj,经过连接后生成的可执行文件的扩展名是.exe 。

6、C 语言的标识符只能由字母、数字和下划线三种字符组成。

第三章数据类型、运算符和表达式一、选择题:1、以下选项中,不正确的 C 语言浮点型常量是( C )。

C语言全部题目及答案

C语言全部题目及答案

C 语言全部题目及答案Exercise1:Programming Environment and Basic Input/Output1. Write a program that prints “This is my first program!” on the screen.(a) Save this program onto your own disk with the name of e2-1a;(b) Run this program without opening Turbo C;(c) Modify this program to print “This is my second program!”, then save it ase2-1b. Please do not overwrite the first program.2. Write a program that prints the number 1 to 4 on the same line. Write the programusing the following methods:(a) Using four “printf” statemen ts.(b) Using one “printf” statement with no conversion specifier (i.e. no ‘%’).(c) Using one “printf” statement with four conversion specifiers3 .(a) Write a program that calculates and displays the number of minutes in 15 days.(b) Write a program that calculates and displays how many hours 180 minutes equal to.(c) (Optional) How about 174 minutes?ANSWERS:#include<stdio.h>int main(){printf("1"); printf("2"); printf("3"); printf("4");return 0;}return 0; }#include<stdio.h>int main(){float days,minutes; days = 15; int main() {printf("This program!");return 0;int main(){float minutes,hours;printf("The numberminutes in 15 are %f\n", minutes);printf("This program!"); int main() {return 0; }#include<stdio.h> #include<stdio.h> #include<stdio.h>of days firstmyisExercise 2: Data Types and Arithmetic Operations1. You purchase a laptop computer for $889. The sales tax rate is 6 percent. Write and execute a C program that calculates and displays the total purchase price (net price + sales tax).2 .Write a program that reads in the radius of a circle and prints the circle’s diameter, circumference and area. Use the value 3.14159 for “ ”.3 .Write a program that reads in two numbers: an account balance and an annual interest rate expressed as a percentage. Your program should then display the new balance after a year. There are no deposits or withdraws – just the interest payment. Your program should be able to reproduce the following sample run:Interest calculation program. Starting balance? 6000Annual interest rate percentage? 4.25}#include<stdio.h>int main() {printf("%d%d%d%d",1,2,3,4);return 0; }hours = minutes / 60; printf("180 minutes equal to %f hours\n", hours);return 0; }#include<stdio.h>int main() {float minutes,hours;#include<stdio.h>int main(){float net_price,sales_tax,total;net_price = 889;sales_tax = net_price * 0.06;total = net_price + sales_tax;printf("The total purchase price is %g", total);return 0;}#include<stdio.h>int main(){printf("Please input a number as radius:\n");float radius,diameter,circumference,area;scanf("%f",&radius);printf("The diameter is %g\n",diameter = radius * 2);printf("The circumference is %g\n",circumference = radius * 2 * 3.14159); printf("The area is %g\n", area = radius * radius * 3.14159);return 0;}#include<stdio.h>{float SB,percentage,NB;printf("Interest calculation program\n\nPlease enter the Starting Balance:"); scanf("%f",&SB);printf("Please enter the Annual interest rate percentage:");scanf("%f",&percentage);NB = SB * percentage / 100 + SB;printf("\nThe Balance after one year is:%g",NB);return 0;}Exercise 3: Selection structure1 . Write a C program that accepts a student’s numerical grade, converts thenumerical grade to Passed (grade is between 60-100), Failed (grade is between 0-59), or Error (grade is less than 0 or greater than 100). 2 . Write a program that asks the user to enter an integer number, then tells theuser whether it is an odd or even number. 3 . Write a program that reads in three integers and then determines and prints thelargest in the group.ANSWER: #include<stdio.h>#include<stdio.h>int main() {#include<stdio.h>int main() {int grade;printf("Please enter the grade:");scanf("%d",&grade);if (grade >= 60 && grade <= 100) printf("Passed."); else if (grade >= 0 && grade <60)#include<stdio.h>int main() {int a,b,c;printf("Please enter 3 integer numbers\n"); printf("Then I'll tell you which is thelargest\n"); scanf("%d%d%d",&a,&b,&c); if (a > b && a > c) printf("%d is the largest",a);else if (b > a && b > c) printf("%d is the largest",b); else if (c > a && c > b)int a;printf("Please enter an integer number\n");printf("Then I'll tell you whether it's an odd or even number");scanf("%d",&a);if (a%2 == 0)printf("%d is an even number",a);elseprintf("%d is a odd number",a);return 0;}Exercise 4: ‘switch’statement and simple “while” repetition statement1. Write a program that reads three integers an abbreviated date (for example: 26 12 94) andthat will print the date in full; for example: 26th December 1994. The day should be followed by an appropriate suffix, ‘st’,‘nd’,‘rd’ or ‘th’. Use at least one switch statement.2 .Write a C program that uses a while loop to calculate and print the sum of the even integersfrom 2 to 30.3. A large chemical company pays its sales staff on a commission basis. They receive £ 200 perweek plus 9% of their gross sales for that week. For example, someone who sells £ 5000 of chemicals in one week will earn £ 200 plus 9% of £5000, a total of £650. Develop a C program that will input each salesperson’s sales for the previous week, and print out their salary.Process one person’s figures at a time.Enter sales in pounds(-1to end):5000.00Salary is:650.00Enter sales in pounds(-1to end):00.00Salary is:200.00Enter sales in pounds(-1to end):1088.89Salary is:298.00Enter sales in pounds(-1to end):-1Optional:4. A mail order company sells five different products whose retail prices are shown in thefollowing table:Product Number1 2Retail Price (in pounds)2.984.503 4 59.98 4.49 6.87Write a C program that reads in a series of pairs of numbers as follows:(1). Product number(2). Quantity sold for one dayYour program should use a switch statement to help determine the retail price for each product, and should use a sentinel-controlled loop to calculate the total retail value of all products sold in a given week (7days).ANSWER:#include<stdio.h>int main(){printf("Please enter three numbers for date:");int day,month,year;scanf("%d %d %d",&day,&month,&year);if(day>31)printf("Error");else{switch (day){case 1:printf("1st");break;case 2:printf("2nd");break;case 3:printf("3rd");break;case 21:printf("21st"); break;case 22:printf("22nd"); break;case 23:printf("23rd"); break;case 31:printf("31st"); break;default:printf("%dth",day); }}switch(month){#include <stdio.h>int main(){int a,b;a=0;b=2;while (b<=30){a=a+b;b=b+2;}printf("The sum of the even integers from 2 to 30 is %d",a);return 0;}Exercise 5: ‘for’ and ‘do … while ” repetition statements1. Write a program which uses a do/while loop to print out the first 10 powers of 2 other than 0 (ie. it prints out the values of 21, 22, ..., 210). Use a for loop to do the same.2. The constant can be calculated by the infinite series:= 4 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11 +....case 1: printf("January ");break;case 2: printf("February ");break;case 3: printf("March ");break;case 4: printf("April ");break;case 5: printf("May ");break;case 6: printf("June ");break;case 7: printf("July ");break;case 8: printf("August ");break;case 9: printf("September ");break;#include<stdio.h> int main() { float a,b;while (a>0 ) {printf("Enter sales in pounds (-1 to end):");scanf("%f",&a); b=200+a*0.09; if (a==-1) printf(" ");else printf("Salary is %.0f\n",b); }return 0;Write a C program that uses a do/while loop to calculate using the series. The program should ask the user how many terms in the series should be used. Thus ifthe user enters ‘3’, then the program should calcula te as being 4 - 4/3 + 4/5.Nested repetition3. Write a program that prints the following diamond shape. You may use printf statements that print either a single asterisk (*) or a single blank. Maximize your use of repetition (with nested for statements) and minimize the number of printf statements.*****************************************4. Write a program to print a table as follows:1*1= 1 2*1= 2 3*1= 3 ….9*1= 9ANSWER:#include<stdio.h> int main(){int a,b;a=0;b=1;do{a++;9*4=36 9*5=459*6=54#include <stdio.h>int main(){double c,pie,p;int a,b,d,n;printf("Enterterms:");scanf("%d",&a);printf("Pie=");9*7=63 9*8=729*9=81#include <stdio.h>int main(){int row,a,b,j;row=1;j=4;while(row<=5){for(a=j;a>=1;a=a-1) printf(" ");2*2= 43*2= 69*3=27 9*2=183*3= 9#include <stdio.h>int main () { int i, j;for (i=1; i<=9; i++) {for (j=1; j<=9; j++) if (i>=j)printf("%1d*%1d=%2d ", i, j, i*j); printf("\n"); }getchar(); return 0;int main() { int a;for(a=2;a<=1024;a=a *2) printf("%d",a); return 0; }p=p+pie;if(n>1&&n<=a) {if(n%2!=0) printf("+"); else printf("-"); }printf("4/%d",d); n++; }printf("\n=%f",p); return 0; }}row=1; j=1;while(row<=5){ for(a=1;a<=j;a=a +1) printf(" "); for(b=1;b<=9-2*j;b++) printf("*"); for(a=1;a<=j;a=a +1) printf(" "); printf("\n"); row++;Exercise 6: Simple Functions1. Write a C program that reads several numbers and uses the functionround_to_nearest to round each of these numbers to the nearest integer.Theprogram should print both the original number and the rounded number.2. Write a program that reads three pairs of numbers and adds the larger of the firstpair,the larger of the second pair and the larger of the third e a function to return the larger of each pair.3.A car park charges a£2.00minimum fee to park for up to3hours,and anadditional£0.50for each hour or part hour in excess of three hours.The maximum charge for any given24-hour period is£10.00.Assume that no car parks for more than24hours at a time.Write a C program that will calculate and print the parking charges for each of3 customers who parked their car in the car park yesterday.The program should accept as input the number of hours that each customer has parked,and output the results in a neat tabular form,along with the total receipts from the three customers:Charge2.002.50 10.0014.50The program should use the function calculate_charges to determine the charge for each customer.ANSWER: #include<stdio.h> int main() {float larger_Number(float,float); float num1,num2,total=0;int a=0;while (a<3) { void round_to_nearest(float); float num; while (5){ total=total+larger_Number(num1,num2);a=a+1; }#include<stdio.h> #include<math.h> int main() {printf("Please input a number:"); scanf("%f",&num);TOTAL Hours 29.524.0 Car 4.0 1.5 2 3 1#include <stdio.h> int main() {float calculate_charges(float);float hour1,hour2,hour3,charge1,charge2,charge3,total1=0,total2=0;printf("Please input three car's parking hours:"); scanf("%f%f%f",&hour1,&hour2,&hour3);charge1=calculate_charges(hour1); charge2=calculate_charges(hour2); charge3=calculate_charges(hour3);printf("Car Hours Charge\n"); printf("1%10.1f%10.2f\n",hour1,charge1); printf("2%10.1f%10.2f\n",hour2,charge2);void round_to_nearest(float num1) {int near_integer; intsmall_integer=floor(num1);if (num1-small_integer>=0.5) near_integer=ceil(num1); elsenear_integer=floor(num1);printf("\nThe nearest integer of the number is:%d\n",near_integer); }printf("\nThe total is %f",total);return 0; }float larger_Number(float num1,float num2) { float larger;if (num1>=num2) {printf("%f",num1); larger=num1; } else {printf("3%10.1f%10.2f\n",hour3,charge3);total1=hour1+hour2+hour3;total2=charge1+charge2+charge3;printf("TOTAL%7.2f%9.2f",total1,total2);return 0;}float calculate_charges(float hour){float charge;if (hour<=3)charge=2;if (hour>3 && hour<=19)charge=2.+0.50*(hour-3.);if (hour>19 && hour<=24)charge=10;return(charge);}Exercise 7: More Functions1.Write a program that uses sentinel-controlled repetition to take an integer as input,and passes it to a function even which uses the modulus operator to determine if the integer is even. The function even should return 1 if the integer is even, and0 if it is not.base exponentThe program should take the value returned by the function even and use it to print out a message announcing whether or not the integer was even.2.Write a C program that uses the function integerPower1(base,exponent)to return the value of:base exponentso that, for example, integerPower1(3, 4) gives the value 3 * 3 * 3 * 3.Assume that exponent is a positive, non-zero integer, and base is an integer.The function should use a for loop, and make no calls to any math library functions.3. Write a C program that uses the recursive function integerPower2(base,exponent) to return the value of:base exponentso that, for example, integerPower2(3, 4) gives the value 3 * 3 * 3 * 3. Assume that exponent is a positive, non-zero integer, and base is an integer.The function should make no calls to any math library functions.(Hint:the recursive step will use the relationship:base exponent=base.base exponent-1and the base case will be when exponent is1since:base1=base.)ANSWER:#include<stdio.h>int main(){int a,b;int judge(int);void judge1(int);printf("Please enter a number");scanf("%d",&a);while(a>=-1){b=judge(a);judge1(b);printf("Please evter a number");scanf("%d",&a);}return 0;}int judge(int x){if (x%2!=0)return (0);elsereturn (1);}void judge1(int x){if (x==1)printf("It's even\n"); elseprintf("It's odd\n");#include<stdio.h>int main(){int integerPower2(int,int);int base,exponent,result;printf("This program cancalculate the power\n");printf("Enter a integer basenumber:\n");scanf("%d",&base);printf("Enter a non-zerointeger number as the exponent:\n");scanf("%d",&exponent);result=integerPower2(base,expo nent);printf("The power is:%d",result); return 0;}int integerPower2(int x,int y){if(y==1)return (x);elsereturn (x*integerPower2(x,y-1)); }#include <stdio.h>int main(){int integerPower1(int,int);int base,exponent,answer;printf("Let us calculate the power\n");} printf("Please enter a integer base number:\n");scanf("%d",&base);printf("Please enter a non-zero integer number asthe exponent:\n");scanf("%d",&exponent);answer=integerPower1(base,exponent);printf("So the power is:%d",answer);return 0;}int integerPower1(int x,int y){int i,a;Exercise 08: Arrays1.Write a program that reads ten numbers supplied by the user into a singlesubscripted array,and then prints out the average of them.2. Write a program that reads ten numbers supplied by the user into a 2 by 5 array,and then prints out the maximum and minimum values held in:(a)each row(2rows)(b) the whole array3 .Use a single-subscripted array to solve the following problem. Read in 20numbers,each of which is between10and100,inclusive.As each number is read, print it only if it is not a duplicate of a number already read.Prepare for the “worst case”in which all 20 numbers are different. Use the smallest possible array to solve this problem.#include<stdio.h>int main(){#define MAXGRADES 10 int grades[MAXGRADES]; int i, total = 0;#include<stdio.h>int main(){#define MAXNUM 5int number[MAXNUM]; int i,j,a;ANSWER: #include<stdio.h> int main() {#define NUMROWS 2 #define NUMCOLS 5int number[NUMROWS][NUMCOLS]; int i,j,max1,max2,min1,min2;for (i=0;i<NUMROWS;i++){ printf("Please input 5 numbers with space between each other:\n"); for (j=0;j<NUMCOLS;j++) scanf("%d",&number[i][j]); }max1=number[0][0]; min1=number[0][0]; max2=number[1][0];{ printf("Enter a number:"); scanf("%d",&grades[i]); }printf("\nThe average of the numbers\n"); for(i=0;i<MAXGRADES;i++) { printf("%d",grades[i]); total+=grades[i]; }average = total/10.0;for(i=0;i<MAXNUM;i++) scanf("%d",&number[i]);a=0;for(i=0;i<MAXNUM;i++) { for(j=0;j<i;j++) {if(number[i]==number[j])a++;}min2=number[1][0];for(j=0;j<NUMCOLS;j++) { if(number[0][j]>=max1) max1=number[0][j];if(number[0][j]<=min1)min1=number[0][j];if(number[1][j]>=max2)max2=number[1][j];if(number[1][j]<=min2)min2=number[1][j];}printf("The max of the first row is %d\n",max1);printf("The min of the first row is %d\n",min1);printf("The max of the second row is %d\n",max2);printf("The min of the second row is %d\n",min2);printf("The max of two rows is ");if (max1>=max2)printf("%d\n",max1);else printf("%d\n",max2);printf("The min of two rows is ");if (min1<=min2)printf("%d\n",min1);else printf("%d\n",min2);return 0;}Exercise 9: More Arrays1. Write a program that enters 5 names of towns and their respective distance (aninteger) from London in miles. The program will print of the names of the towns that are less than 100 miles from London. Use arrays and character strings to implement your program.2. Write a program that prompts the user to type in four character strings, placesthese in an array of strings, and then prints out: (e.g. I am Peter Pan)(i) The four strings in reverse order. (e.g. Pan Peter am I)(ii) The four strings in the original order, but with each string backwards. (e.g. I ma reteP naP)(iii) The four strings in reverse order with each string backwards. (e.g. naP reteP ma I)#include<stdio.h>int main(){char character[5][20];int integer[5];int i;for(i=0;i<5;i++){ printf("Please enter a name of a town:\n");scanf("%s",character[i]);printf("Enter its distance from London in miles:\n");scanf("%d",&integer[i]);}printf("The towns that are less than 100 miles from London are:\n"); for(i=0;i<5;i++){if(integer[i]<100)printf("%s",character[i]);}return 0;}Exercise 10: Pointers1. Write a program that reads 5 integers into an array, and then uses four differentmethods of accessing the members of an array to print them out in reverse order.//Pan Peter am I #include<stdio.h> int main() {char four[4][81]; int i;printf("Please input four words:\n");for(i=0;i<4;i++) scanf("%s",four[i]);printf("The four strings in reverse order is :\n"); for(i=3;i>=0;i--) { printf("%s",four[i]);//naP reteP ma I #include <stdio.h> int main() {char four[4][81]; int i,j;printf("Please input four words:\n"); for(i=0;i<4;i++)scanf("%s",four[i]); printf("The four strings are:\n"); for(i=3;i>=0;i--) {for(j=0;four[i][j]!='\0';j++); for(j=j-1;j>=0;j--) {2. Write a program that reads 8 floats into an array and then prints out the second,fourth, sixth and eighth members of the array, and the sum of the first, third, fifth and seventh, using pointers to access the members of the array.3. (Optional) Write a program that use a SINGLE FUNCTION (用一个函数)tofind and return simultaneously both the lowest and highest values in an array of type int. Suppose the size of the array is 6.ANSWER:#include<stdio.h>int main(){int num1[5],i;printf("Please input 5 numbers:\n");for (i=0;i<5;i++)scanf("%d",&num1[i]);//the first wayprintf("\nPrint them out in reverse order in the first way:\n");for (i=4;i>=0;i--)printf("%d",num1[i]);//the second wayprintf("\nPrint them out in reverse order in the second way:\n");int *num2;num2 = &num1[0];for (i=4;i>=0;i--)printf("%d",*(num2+i));//the third wayprintf("\nPrint them out in reverse order in the third way:\n");for(i=4;i>=0;i--)printf("%d",*(num1+i));//the fourth wayprintf("\nPrint them out in reverse order in the fourth way:\n");int *num4;num4 = &num1[4];for (i=0;i<5;i++)printf("%d",*(num4-i));return 0;}#include<stdio.h>int main(){float num[8];int i;printf("Please input 8 floats:\n");for (i=0;i<8;i++)scanf("%f",&num[i]);//first, print out the second,fourth,sixth and eighthmembers of the arrayfor (i=1;i<8;i=i+2)printf("%f",*(num+i));//second, print out the sum of thefirst,third,fifthand seventhfloat total;for (i=0;i<8;i=i+2)total = total+*(num+i); #include<stdio.h>void SingleFunction(int *,int *); int main(){int num[6];int i;printf("Please input 6numbers:\n"); for (i=0;i<6;i++)scanf("%d",&num[i]);SingleFunction(num,num); return 0;}void SingleFunction(int *max,int *min) {int i,maxnum,minnum; maxnum = *max++;minnum = *min++;for(i=-1;i<5;i++)。

C语言全部考试系统题库含答案(可编辑修改word版)

C语言全部考试系统题库含答案(可编辑修改word版)
-
目录
目录................................................................1 单元练习题一 C 语言基础知识 .........................................3
一、 判断题 ...................................................3 二、 单项选择题 ...............................................4 三、 读程序选择题 .............................................7 四、程序填空题 ..................................................8 五、编程题 .....................................................10 单元练习题二 C 语言程序结构 ........................................10 一、 判断题 ..................................................10 二、 单项选择题 ..............................................11 三、 读程序选择题 ............................................18 四、 程序填空题 ..............................................30 五、 编程题 ..................................................35 单元练习题三 数组..................................................36 一、 判断题 ..................................................36 二、 单项选择题 ..............................................37 三、读程序选择题 ...............................................39 四、程序填空题 .................................................43 五、编程题 .....................................................49 单元练习题四 函数..................................................49 一、 判断题 ..................................................49 二、 单项选择题 ..............................................50 三、读程序选择题 ...............................................52 四、程序填空题 .................................................60 五、编程题 .....................................................63 单元练习题五 预处理................................................63 一、 判断题 ..................................................63 二、 单项选择题 ..............................................64 三、读程序选择题 ...............................................64 四、程序填空题 .................................................65 五、编程题 .....................................................65 单元练习题六 指针..................................................66 一、 判断题 ..................................................66 二、 单项选择题 ..............................................66 三、读程序选择题 ...............................................67 四、程序填空题 .................................................74 五、编程题 .....................................................77 单元练习题七 结构体与共用体........................................78 一、 判断题 ..................................................78 二、 单项选择题 ..............................................78

c语言试题及答案

c语言试题及答案

c语言试题及答案C语言试题及答案一、选择题1. 在C语言中,以下哪个是正确的数据类型?A. 整数型B. 浮点型C. 字符型D. 所有选项答案:D2. 以下哪个是C语言中的逻辑运算符?A. &&B. ||C. !D. 所有选项答案:D3. 在C语言中,哪个关键字用于定义一个函数?A. intB. voidC. functionD. return答案:A二、填空题1. 在C语言中,一个基本的程序结构由_____、_____、_____三个部分组成。

答案:预处理指令;函数定义;语句2. 一个C语言程序总是从_____函数开始执行。

答案:main3. 在C语言中,若要实现循环,可以使用_____、_____、_____等循环结构。

答案:for;while;do-while三、简答题1. 简述C语言中数组的定义和使用。

答案:在C语言中,数组是一种数据结构,用于存储具有相同数据类型的元素集合。

数组定义的一般形式为:类型名数组名[常量表达式],其中类型名是数组元素的数据类型,数组名是数组的标识符,常量表达式是数组中元素的数量。

数组的使用包括初始化、访问和修改元素等。

2. 解释C语言中的指针及其作用。

答案:指针是C语言中一种特殊的变量,它存储了另一个变量的内存地址。

指针的主要作用是直接访问和操作内存地址,从而可以更灵活地处理数据。

指针的使用包括指针的声明、指针的初始化、指针的运算等。

四、编程题1. 编写一个C语言程序,实现求两个整数的和。

```c#include <stdio.h>int main() {int num1, num2, sum;printf("请输入两个整数:");scanf("%d %d", &num1, &num2);sum = num1 + num2;printf("两个整数的和是:%d\n", sum); return 0;}```2. 编写一个C语言程序,实现字符串的反转。

C语言200道练习题及答案

C语言200道练习题及答案
数组与字符串练习题
一维数组
题目1
题目2
题目3
题目4
求一维数组中的最大值 和最小值。
将一维数组中的元素逆 序存放。
查找一维数组中指定的 元素,并返回其下标。
求一维数组中所有元素 的和。
二维数组
题目5
题目6
求二维数组中所有元素的最大值和最小值 。
将二维数组转置,即行列互换。
题目7
题目8
查找二维数组中指定的元素,并返回其位 置。
C语言200道练习题 及答案
汇报人:XX
目录
• 基础知识练习题 • 数组与字符串练习题 • 函数与模块化练习题 • 指针与内存管理练习题 • 数据结构与算法练习题 • 综合应用练习题
01
基础知识练习题
变量与数据类型
声明整型变量并赋值
int a = 10;
声明字符型变量并赋值
char c = 'A';
代码优化
通过减少不必要的计算、消 除冗余代码等方式对代码进 行优化。
并行计算与多线程
了解并行计算和多线程的基 本概念,探索在程序中应用 并行计算和多线程技术提高 性能的可能性。
THANKS
感谢观看
掌握如何使用malloc()、calloc() 等函数在堆区动态分配内存空间

动态内存释放函数
了解如何使用free()函数释放之前 分配的内存空间,以避免内存泄漏 。
内存分配失败处理
熟悉在动态内存分配过程中,如何 处理分配失败的情况,如检查返回 值是否为NULL等。
05
数据结构与算法练习题
结构体与联合体
01
掌握如何定义指向函数的指针变量,以及如何通过函数指针调
用函数。

c语言基础试题及答案

c语言基础试题及答案

c语言基础试题及答案一、选择题1. C语言中,以下哪个关键字用于定义一个结构体?A. structB. unionC. enumD. typedef答案:A2. 在C语言中,以下哪个运算符用于取地址?A. *B. &C. %D. #答案:B3. 下列哪个选项是C语言中的合法整数常量?A. 0x12B. 0X12C. 0x1GD. 0x1g答案:A4. C语言中,以下哪个函数用于计算字符串的长度?A. strlen()B. strcpy()C. strcat()D. strcmp()答案:A5. 在C语言中,以下哪个关键字用于定义一个函数?A. functionB. defC. defineD. void答案:D二、填空题1. C语言中,用于定义一个变量的关键字是________。

答案:int2. C语言中,用于定义一个数组的语法是________。

答案:type arrayName[arraySize];3. C语言中,用于定义一个指针的语法是________。

答案:type *pointerName;4. C语言中,用于定义一个函数的语法是________。

答案:type functionName(parameters);5. C语言中,用于定义一个枚举的语法是________。

答案:enum enumName {elements};三、简答题1. 简述C语言中指针和数组的关系。

答案:在C语言中,指针和数组有密切的关系。

指针可以指向数组的元素,数组名可以作为指向数组首元素的指针。

通过指针可以访问和修改数组中的元素。

2. 描述C语言中函数的调用过程。

答案:在C语言中,函数调用过程包括:调用函数、传递参数、执行函数体、返回结果。

调用函数时,程序控制权转移到被调用函数,函数执行完毕后,返回到调用点继续执行。

四、编程题1. 编写一个C语言程序,实现计算两个整数的和。

答案:```c#include <stdio.h>int main() {int num1, num2, sum;printf("Enter two numbers: ");scanf("%d %d", &num1, &num2);sum = num1 + num2;printf("The sum is: %d\n", sum);return 0;}```2. 编写一个C语言程序,实现字符串的反转。

C语言常见复习题(选择填空)及参考答案

C语言常见复习题(选择填空)及参考答案

C语言常见复习题及参考答案一、选择题1.下述标识符中,()是合法的用户标识符。

A.A#CB.getchC.voidD.ab*2.在C语言中,字符型数据在内存中是以()形式存放的。

A.原码B.BCD码C.反码D.ASCII码3.以下选项中不合法的用户标识符是()。

A.abc.cB.fileC.MainD.PRONTF4.以下选项中不合法的用户标识符是()。

A.123B.printfC.Anbsp;D.Dim5.可以在C语言程序中用做用户标识符的一组标识符是()。

A.voidB.as-b3C.forD.2cdefine -123 -abc DoWORD If cas SIG6.在以下各组标识符中,合法的用户标识符是(1)、(2)、(3)。

(1)A.001 B.table_1 C.0_t D.k%Int t*.1 W10 point(2)A.Fast_ B.void C.pbl D.Fast+Big abs fabs beep(3)A.xy_ B.longdouble C.*p D.CHAR变量1 signed history Float7.()是构成C语言的基本单位。

A.函数B.过程C.子程序D.子例程8.若有说明:char s1='\067';char s2="1";char s3='1';则s1中(1),s2中(2),s3中(3)。

(1).A.包含3个字符 B.包含2个字符C.包含1个字符D.无定值,说明不合法(2).A.包含1个字符 B.包含2个字符C.包含3个字符D.无定值,说明不合法(3).A.包含1个字符 B.包含2个字符C.包含3个字符D.无定值,说明不合法9.若x为int型变量,则执行以下语句后,x的值为x=6;x+=x-=x*xA.36B.-60C.60D.-2410.在C语言中,char 型数据在内存中是以()形式存储的。

A.原码B.补码C.ASCII码D.反码11.以下运算符中优先级最低的算符为(),优先级最高的为()。

c语言考试题库及答案

c语言考试题库及答案

c语言考试题库及答案C语言考试题库及答案一、选择题1. C语言中,用于表示逻辑“与”操作的关键字是()。

A. &&B. ||C. &D. or答案:A2. 下列哪个选项是C语言中的合法整型常量?A. 0x10FB. 01FC. 8181D. 0.8181答案:A3. 在C语言中,定义一个字符变量可以使用哪种数据类型?A. intB. floatC. charD. double答案:C4. 下列哪个函数用于计算字符串的长度?A. strlen()B. strcmp()C. strcpy()D. printf()答案:A5. C语言中,若要交换两个变量的值,通常使用哪种方法?A. 递归调用B. 位运算C. 三元运算符D. 临时变量答案:D二、填空题1. 在C语言中,使用关键字________声明一个全局变量。

答案:extern2. 一个C语言程序的执行是从________函数开始的。

答案:main3. 在C语言中,使用________运算符可以实现对整型数值的强制类型转换为浮点型。

答案:(float)4. 为了在C语言中定义一个无限循环,可以使用________语句。

答案:while(1)5. 当需要在C语言中动态分配内存时,可以使用函数________。

答案:malloc三、判断题1. C语言中的数组下标是从1开始的。

(错)答案:错2. 在C语言中,函数可以作为另一个函数的参数传递。

(对)答案:对3. C语言中,结构体是一种可以包含不同数据类型成员的用户自定义数据类型。

(对)答案:对4. 使用C语言编写的程序在运行时,所有的变量存储在堆内存中。

(错)答案:错5. C语言中的指针变量必须在使用前初始化。

(错)答案:错四、简答题1. 请简述C语言中的指针和引用的主要区别。

答案:指针是一个变量,其值为另一个变量的地址,而引用是另一个变量的别名,它必须在定义时初始化,并且不能重新指向其他变量。

c语言基础习题、复习题(含答案).doc

c语言基础习题、复习题(含答案).doc

《C语言设计》复习题一选择题1、以下说法中正确的是(C )。

C语言程序总是从main。

函数开始执行2、若已定义x和y为double类型,则表达式:x=l, y=x+^2的值是一C・C. 2.03、以下叙述正确的是口。

D.用do・・・while语句构成循环时,在while后的表达式为零时结束循环4、C程序是由)B.从Main函数开始5、设x、y、z和k都是int型变量,则执行表达式:x= (y=4, z=16, k=32)后,x 的值为C 。

C.326、设intb=2;表达式b/(b*2)的值是A ・A.07、表示关系X<=Y<=Z的C语言表达式为A .A.(X < =Y)&&(Y < =Z)8、已知int x=10,y=20,z=30;以下语句执行后x,y,z的值是典B.x=20,y=30,z=309、设A=3,B=4,执行printf("%d,%d",(A,B),(B,A));的输出是B .B.4,310、下面判断正确的是CC.char *s="china";等价于char *s;s="china";11、若有说明:inta[10];,则对a数组元素的正确引用是D.a[10-10]12在C语言中,int> char和short三种类型数据在内存中所占用的字节数D.由所用机器的机器字长决定13、C语言规定,函数返回值的类型是由必D.在定义该函数时所指定的函数类型所决定14、与y=(x>0?l:x<0?-l:0);的功能相同的if语句是AA.if(x > 0) y=l; else if(x < 0) y=-l; else y=015、执行语句:for(i=l;i++<4;)后;变量i的值是(C )C.516^语句while(!E);中的表达式!E等价于AA.E==017、假定a和b为int型变量,则执行以下语句后b的值为D.-418、对以下说明语句的宜确理解是Binta[10]={6,7,8,9,10};B.将5个初值依次赋给a[0]至a[4]19、以下不能对二维数组a进行正确初始化的语句是MC.inta[2][3]={{l,2},{3,4},{5,6}};20、在C语言中,一维数组的定义方式为:类型说明符数绢名DD.[整型常量]21、下列说法中正确的是oD.初始化值列表中的值的个数多于数组元素的22、若二维数组a有m列,则在a[i][j]前的元素个数为BB.i*m+j23、以下选项中,不能正确赋值的是工A.char sl[10];sl="Ctest";24、以下程序的输出结果是共B."BBB"25、设有数组定5C: char array [ ]="China";则数组array 所占的空间为£C.6个字节26、变量的指针,其含义是指该变量的典B.地址27、下面能正确进行字符串赋值操作的是MC.char*s;s="ABCDE";28、C语言中,调用一个函数时,实参变量和形参变量之间的数据传递是A .A.单纯值传递29、C语言中A函数的递归调用。

c语言程序基础练习题500道(附答案)

c语言程序基础练习题500道(附答案)

c语言程序基础练习题500道(附答案)1.下列四组选项中,均不是C语言关健字的选项是( A )。

A) define B) gect C) include D) whileIF char scanf gotype printf case pow2.下面四个选项中,均是合法整型常量的选项是( A )。

A)160 B)-0xcdf C) -01 D)-0x48a-0xffff 01a 986,012 2e5011 0xe 0668 0x3.下面四个选项中,均是不合法的转义符的选项是( B )。

A) '\"' B) '\1011' C) '\011' D) '\abc''\\' '\' '\f' '\101''xf' '\A' '\}' 'x1f'4.下面不正确的字符串常量是( A )。

A)'abc' B)"12'12" C)"0" D)" "5.以下选项中不合法的用户标识符是( A )。

A)abc.c B)file C)Main D)PRINT6.C语言提供的合法关键字是( D )。

A) swithB) cherC) CaseD)default7.下列标识符组中,合法的用户标识符为 AA)_0123与ssipedB)del-word与signedC)list与*jerD) keep%与wind8.在C语言中,逻辑值"真"的表示是用( C )。

A) true B) 整型值0 C)非另整型值D) T9若有以下定义char s='\092';则该语句( b )A)使s的值包含一个字符B)定义不合法,s的值不确定C)使s的值包含4个字符D)使s的值包含3个字符10设C语言中,int类型数据占2个字节,则float类型数据占(D )个字节。

C语言经典练习题50道(附答案)

C语言经典练习题50道(附答案)

1.**打印Hello World**练习:编写一个C程序,打印"Hello,World!"到屏幕上。

#include<stdio.h>int main(){printf("Hello,World!\n");return0;}2.**计算两个整数的和**练习:编写一个程序,接受两个整数,然后计算它们的和并打印结果。

#include<stdio.h>int main(){int a=5,b=7;int sum=a+b;printf("Sum:%d\n",sum);return0;}3.**判断奇数或偶数**练习:编写一个程序,接受一个整数,然后判断它是否为奇数或偶数。

#include<stdio.h>int main(){int num=10;if(num%2==0){printf("%d is even.\n",num);}else{printf("%d is odd.\n",num);}return0;}4.**计算阶乘**练习:编写一个程序,计算给定整数的阶乘。

#include<stdio.h>int main(){int n=5;int factorial=1;for(int i=1;i<=n;i++){factorial*=i;}printf("Factorial of%d is%d\n",n,factorial);return0;}5.**反转字符串**练习:编写一个程序,接受一个字符串,然后反转它并打印出来。

#include<stdio.h>#include<string.h>int main(){char str[]="Hello,World!";int len=strlen(str);for(int i=len-1;i>=0;i--){printf("%c",str[i]);}printf("\n");return0;}6.**检查素数**练习:编写一个程序,判断一个整数是否为素数。

(完整版)C语言考试题库及答案

(完整版)C语言考试题库及答案

(完整版)C语言考试题库及答案一、选择题1. 以下哪个选项是C语言的合法标识符?A. intB. 2abcC. voidD. a+b答案:C2. 在C语言中,下列哪个选项是正确的数据类型?A. floatB. integerC. doubleD. All of the above答案:D3. 若变量定义如下:int a = 5;,则执行语句printf("%d", a++); 后,a的值是多少?A. 4B. 5C. 6D. 无法确定答案:C4. 以下哪个函数用于动态分配内存?A. malloc()B. alloc()C. new()D. calloc()答案:A5. 在C语言中,哪个运算符用于取模(取余)?A. %B. /C. &D. |答案:A以下是判断题部分:6. C语言中的数组名可以作为指向该数组首元素的指针使用。

()答案:正确7. 在C语言中,结构体变量可以作为函数的参数传递。

()答案:正确8. 在C语言中,静态存储类别的变量在程序运行期间始终占据内存空间。

()答案:正确二、填空题9. 在C语言中,定义一个整型变量需要使用关键字______。

答案:int10. 若变量定义如下:int a = 10;,则执行语句printf("%d", a--); 后,a的值是______。

答案:911. 在C语言中,用于动态分配内存的函数是______。

答案:malloc12. 在C语言中,用于释放动态分配的内存的函数是______。

答案:free13. 在C语言中,用于清空标准输入缓冲区的函数是______。

答案:getchar()三、编程题14. 编写一个C语言程序,实现以下功能:输入一个整数,输出它的阶乘。

答案:```c#include <stdio.h>int main() {int n, i;long factorial = 1;printf("Enter an integer: ");scanf("%d", &n);if (n < 0) {printf("Factorial of a negative number doesn't exist.\n");} else {for (i = 1; i <= n; i++) {factorial = i;}printf("Factorial of %d is %ld\n", n, factorial);}return 0;}```15. 编写一个C语言程序,实现以下功能:输入一个字符串,判断它是否是回文(正读和反读都一样的字符串)。

c语言考试试题及答案

c语言考试试题及答案

c语言考试试题及答案C语言考试试题及答案一、选择题(每题2分,共20分)1. 下列哪个选项是C语言的关键字?A. voidB. StringC. intD. array答案:A2. C语言中,哪个运算符用于计算两个数的乘积?A. +B. -C. *D. /答案:C3. 在C语言中,以下哪个是正确的字符串定义?A. char str[10] = "Hello";B. string str = "Hello";C. char str[] = "Hello";D. string str[10] = "Hello";答案:A4. 下列哪个选项是C语言中数组的正确声明方式?A. int array[10];B. int array(10);C. int array = 10;D. int array = {10};答案:A5. 在C语言中,哪个函数用于计算两个数的最大值?A. max()B. min()C. abs()D. pow()答案:A6. 以下哪个是C语言中的逻辑运算符?A. &&B. ||C. %D. /答案:A7. 在C语言中,哪个关键字用于定义一个函数?A. functionB. defC. voidD. int答案:C8. C语言中,以下哪个语句用于结束一个循环?A. continue;B. break;C. return;D. exit;答案:B9. 在C语言中,哪个函数用于打印输出?A. printf()B. print()C. display()D. show()答案:A10. 以下哪个选项是C语言中正确的条件语句?A. if (x = 10)B. if (x == 10)C. if (x : 10)D. if (x / 10)答案:B二、填空题(每空2分,共20分)1. C语言中,用于定义变量的关键字是________。

(完整版)C语言基础练习题(含答案)(可编辑修改word版)

(完整版)C语言基础练习题(含答案)(可编辑修改word版)

目录第1-3 章C 语言基础知识习题 (2)1选择题 (2)2填空题 (7)3答案及部分解析 (9)第4 章选择结构习题 (11)1选择题 (11)2填空题 (17)3答案及部分解析 (23)第5 章循环结构习题 (26)1 选择题 (26)2 填空题: (32)3 答案及部分解题分析 (39)第6 章数组习题 (41)1.单项选择题 (41)2.填空题 (44)3.判断题 (45)4.程序填空题 (45)5.阅读程序,分析程序的功能。

(49)第7 章函数习题 (55)1.单项选择题 (55)2.填空题 (56)3.判断题 (57)4.程序填空题 (58)5.写出下列程序运行结果 (59)第8 章指针习题 (67)1选择题 (67)2填空题 (69)第1-3 章C 语言基础知识习题1选择题1.以下不是C 语言的特点的是()。

A、语言简洁紧凑B、能够编制出功能复杂的程序C、C 语言可以直接对硬件操作D、C 语言移植性好2.下列字符序列中,不可用作C 语言标识符的是()。

A.abc123 B.no.1 C._123_ D._ok3.正确的C 语言标识符是()。

A._buy_2 B.2_buy C.?_buy D.buy?4.请选出可用作C 语言用户标识符的一组标识符()。

A.void B.a3_b3 C.For D.2adefine _123 -abc DOWORD IF Case sizeof5.下列符号中,不属于转义字符的是()。

A.\\ B.\0xAA C.\t D.\06.不属于C 语言关键字的是()。

A.int B.break C.while D.character7.是C 语言提供的合法关键字的是()。

A.Float B.signed C.integer D.Char8.以下不能定义为用户标示符的是()。

A.scanf B.Void C._3com_ D.int9.一个C 程序是由()。

C语言考试题库及答案

C语言考试题库及答案

C语言(共200题)1、下面程序的输出是___D______#include<>void main(){ int k=11;printf("k=%d,k=%o,k=%x\n",k,k,k);}A) k=11,k=12,k=11 B) k=11,k=13,k=13 C) k=11,k=013,k=0xb D) k=11,k=13,k=b2、在下列选项中,不正确的赋值语句是__D______.A) ++t; B) n1=(n2=(n3=0));C) k=i=j; D) a=b+c=1;3、下面合法的C语言字符常量是______A____.A) '\t' B) "A" C) 65 D) A4、表达式: 10!=9的值是________D____.A) true B) 非零值 C) 0 D) 15、C语言提供的合法的数据类型关键字是_____B____.A) Double B) short C) integer D) Char6、字符(char)型数据在微机内存中的存储形式是__D__.A) 反码 B) 补码 C) EBCDIC码 D) ASCII码7、C语言程序的基本单位是_____C______.A) 程序行 B) 语句 C) 函数 D) 字符8、设 int a=12,则执行完语句a+=a-=a*a后,a的值是____D____A) 552 B) 264 C) 144 D) -2649、执行下面程序中的输出语句后,输出结果是____B__.#include<>void main(){int a;printf("%d\n",(a=3*5,a*4,a+5));}A) 65 B) 20 C) 15 D) 1010、下面程序的输出是____B______.#include<>void main(){int x=023;printf("%d\n",--x);}A) 17 B) 18 C) 23 D) 2411、下面程序的输出的是_____C____.#include<>void main(){int x=10,y=3;printf("%d\n",y=x/y);}A) 0 B) 1 C) 3 D) 不确定的值12、已知字母A的ASCII码为十进制的65,下面程序的输出是______A_____.#include<>void main(){char ch1,ch2;ch1='A'+'5'-'3';ch2='A'+'6'-'3';printf("%d,%c\n",ch1,ch2);}A) 67,D B) B,C C) C,D D) 不确定的值13、若要求在if后一对圆括号中表示a不等于0的关系,则能正确表示这一关系的表达式为____D__.A) a<>0 B) !a C) a=0 D) a14、以下程序的输出结果是____D_____.#include<>void main(){ int x=10,y=10;printf("%d %d\n",x--,--y);}A) 10 10 B) 9 9 C) 9 10 D) 10 915、设有如下定义:int x=10,y=3,z;则语句printf("%d\n",z=(x%y,x/y));的输出结果是_____D_____.A) 1 B) 0 C) 4 D) 316、为表示关系x≥y≥z,应使用C语言表达式___A___.A) (x>=y)&&(y>=z) B) (x>=y)AND(y>=z) C) (x>=y>=z) D) (x>=y) & (y>=z)17、C语言中非空的基本数据类型包括____B____.A) 整型,实型,逻辑型 B) 整型,实型,字符型C) 整型,字符型,逻辑型D) 整型,实型,逻辑型,字符型18、若x和y都是int型变量,x=100,y=200,且有下面的程序片段:printf("%d",(x,y));上面程序片段的输出结果是____A___.A) 200 B) 100C) 100 200 D) 输出格式符不够,输出不确定的值19、阅读下面的程序#include<>void main(){char ch;scanf("%3c",&ch);printf("%c",ch);}如果从键盘上输入abc<回车>则程序的运行结果是__A_____.A) a B) b C) c D) 程序语法出错20、阅读下面的程序#include<>void main(){int i,j;i=010;j=9;printf("%d,%d",i-j,i+j);}则程序的运行结果是____D____.A) 1,19 B) -1,19 C) 1,17 D) -1,1721、阅读下面的程序#include<>void main(){int i,j,m,n;i=8;j=10;m=++i;n=j++;printf("%d,%d,%d,%d",i,j,m,n);}程序的运行结果是______C____.A) 8,10,8,10 B) 9,11,8,10C) 9,11,9,10 D) 9,10,9,1122、已知a=12,则表达式a+=a-=a*=a的结果是_____A__.A) 0 B) 144 C) 12 D) -26423、若已定义int a,则表达式a=10,a+10,a++的值是__B_.A) 20 B) 10 C) 21 D) 1124、阅读下面的程序#include<>void main(){int i,j;scanf("%3d%2d",&i,&j);printf("i=%d,j=%d\n",i,j);}如果从键盘上输入1234567<回车>,则程序的运行结果是____D____.A) i=123,j=4567 B) i=1234,j=567C) i=1,j=2 D) i=123,j=4525、下面程序的输出结果是____D____.#include<>void main(){int a=-1, b=4, k;k=(++a<=0)&&(b--<=0);printf("%d,%d,%d\n",k,a,b);}A) 1,1,2 B) 1,0,3 C) 0,1,2 D) 0,0,326、下面程序的输出结果是____A____.#include<>void main(){int a=5,b=3;float x=, y=;printf("%d,%d\n",a+b!=a-b,x<=(y-=);}A) 1,0 B) 0,1 C) 1,1 D) 0,027、执行下面程序段后,输出结果是____A____.int a;int b=65536;a=b;printf("%d\n",a);A) 65536 B) 0 C) -1 D) 128、若有以下定义和语句:int a=010, b=0x10, c=10;printf("%d,%d,%d\n",a,b,c);则输出结果是____B_____.A) 10,10,10 B) 8,16,10 C) 8,10,10 D) 8,8,1029、已知有double型变量x=,y=,整型变量a=7,则表达式x+a%3*(int)(x+y)%2/4 的值是_____B____.A) B) 2.5 C) D) 030、若已定义x和y是整型变量,x=2;,则表达式y=+x/2的值是____C____.A) B) 5 C) 3 D)31、以下程序的输出结果是____D____.#include<>void main(){int a=12, b=12;printf("%d,%d\n",--a,++b);}A) 10,10 B) 12,12 C) 11,10 D) 11,1332、设有以下语句:int x=10;x+=3+x%(3),则x的值是.____A_____A) 14 B) 15 C) 11 D) 1233、若d为double型变量,则表达式d=1,d+5,d++的值是_____D__.A) 1 B) 6.0 C) D)34、表达式5!=3的值是____D____.A) T B) 非零值 C) 0 D) 135、若有定义int a=12,n=5,则表达式a%=(n%2)运算后,a的值______A____.A) 0 B) 1 C) 12 D) 636、若有定义int x=3,y=2和float a=,b=,则表达式:(x+y)%2+(int)a/(int)b的值是__D__.A) 0 B) 2 C) D) 137、在C语言中,以下叙述不正确的是_____A____.A) 在C程序中,无论是整数还是实数,都能被准确无误的表示B) 在C程序中,变量名代表存储器中的一个位置C) 静态变量的生存期与整个程序的生存期相同D) C语言中变量必须先定义后引用38、C语言中的变量名只能由字母,数字和下划线三种字符组成,且第一个字符____C____.A) 必须为字母B) 必须为下划线C) 必须为字母或下划线D) 可以是字母,数字或下划线中的任意一种39、设有说明:char w; int x; float y; double z; 则表达式: w*x+z-y值的数据类型是___D____.A) float B) char C) int D) double40、一个C语言的执行是从_____A______.A) 本程序的主函数开始,到本程序的主函数结束B) 本程序的第一个函数开始,到本程序的最后一个函数结束C) 本程序的主函数开始,到本程序的最后一个函数结束D) 本程序的第一个函数开始,到本程序的主函数结束41、设a为整型变量,不能正确表达数学关系10<a<15的C语言表达式是____A____.A) 10<a<15 B) a==11||a==12||a==13||a==14C) a>10&&a<15 D) !(a<=10)&&!(a>=15)42、下列程序执行后的输出结果是_____C____.#include <>void main( ){ int a=5,b=60,c;if (a<b){c=a*b;printf("%d*%d=%d\n",b,a,c);}else{c=b/a;printf("%d/%d=%d\n",b,a,c);}}A) 60/5=12 B) 300 C) 60*5=300 D) 1243、如果c为字符型变量,判断c是否为空格不能使用____A____.(假设已知空格ASCII码为32)A) if(c=='32') B) if(c==32)C) if(c=='\40') D) if(c==' ')44、运行下面程序时,若从键盘输入"3,5<CR>",则程序的输出结果是____D____.#include <>void main( ){int x,y;scanf("%d,%d",&x,&y);if (x==y)printf("x==y");else if (x>y)printf("x>y");elseprintf("x<y");}A) 3<5 B) 5>3 C) x>y D) x<y45、运行下面程序时,若从键盘输入数据为"6,5,7<CR>",则输出结果是____C___.#include <>void main( ){ int a,b,c;scanf("%d,%d,%d",&a,&b,&c);if (a>b)if (a>c)printf("%d\n",a);elseprintf("%d\n",c);elseif (b>c)printf("%d\n",b);elseprintf("%d\n",c);}A) 5 B) 6 C) 7 D) 不定值46、执行下面程序时,若从键盘输入"2<CR>",则程序的运行结果是____A____.#include <>void main( ){ int k; char cp;cp=getchar( );if (cp>='0' && cp<='9')k=cp-'0';else if (cp>='a' && cp<='f')k=cp-'a'+10; else k=cp-'A'+10;printf("%d\n",k);}A) 2 B) 4 C) 1 D) 1047、运行下面程序时,从键盘输入"<CR>",则输出结果是___B_____.#include <>void main( ){ float a,b;scanf("%f",&a);if (a< b=;else if ((a< && (a!=) b=(a+;else if (a< b=2;else b=;printf("%f\n",b);}A) B)C) D)48、执行下面程序后,运行结果是____A____.#include <>void main( ){ int x=41,y=1;if (x%3==0 && x%7==0){ y+=x;printf("y=%d\n",y);}else{y=x;printf("y=%d",y);}}A) y=41 B) y=43 C) y=42 D) y=149、运行下面程序时,从键盘输入"12,34,9<CR>",则输出结果是___A___.#include <>void main( ){ int x,y,z;scanf("%d,%d,%d",&x,&y,&z);if (x<y)if (y<z)printf("%d\n",z);else printf("%d\n",y);else if (x<z)printf("%d\n",z);else printf("%d\n",x);}A) 34 B) 12 C) 9 D) 不确定的值50、运行下面程序时,从键盘输入字母H,则输出结果是_____C___.#include <>void main( ){ char ch;ch=getchar( );switch(ch){ case 'H':printf("Hello!\n");case 'G':printf("Good morning!\n");default:printf("Bye_Bye!\n");}}A) Hello! B) Hello!Good Morning!C) Hello! D) Hello!Good morning! Bye_Bye!Bye_Bye!51、执行下列程序段后的输出结果是_____A____.int x=1,y=1,z=1;x+=y+=z;printf("%d\n",x<y?y:x);A) 3 B) 2 C) 1 D) 452、设ch是char型变量,值为'A',则表达式ch=(ch>='A' && ch<='Z')?ch+32:ch的值是__B___.A) Z B) a C) z D) A53、下面程序的输出结果是____C____.#include <>void main( ){ int x=8,y=-7,z=9;if (x<y)if (y<0) z=0;else z-=1;printf("%d\n",z);}A) 8 B) 1 C) 9 D) 054、运行下面程序时,若从键盘输入"5 <CR>",则程序的输出结果是_____B___.#include <>void main( ){ int a ;scanf("%d",&a);if (a++>5)printf("%d\n",a);else printf("%d\n",a--) ;}A) 7 B) 6 C) 5 D) 455、运行下面程序时,若从键盘输入"3,4 <CR>",则程序的输出结果是____B___.#include <> void main( ){ int a,b,s;scanf("%d,%d",&a,&b);s=a;if (s<b) s=b;s=s*s;printf("%d\n",s) ;}A) 14 B) 16 C) 18 D) 2056、下列程序的执行结果是_____D____.#include <>void main( ){ int x=0,y=1,z=0;if (x=z=y)x=3;printf("%d,%d\n",x,z);}A) 3,0 B) 0,0 C) 0,1 D) 3,157、假定等级和分数有以下对应关系:等级:A 分数:85~100等级:B 分数:60~84等级:C 分数:60 以下对于等级grade输出相应的分数区间,能够完成该功能的程序段是____D____.A) switch (grade){case 'A':printf("85--100\n");case 'B':printf("60--84\n");case 'C':printf("60以下\n");default:printf("等级错误!\n");}B) switch (grade){case 'A':printf("85--100\n");break;case 'B':printf("60--84\n");case 'C':printf("60以下\n");default:printf(" 等级错误!\n");}C) switch (grade){case 'A':printf("85--100\n");break;case 'B':printf("60--84\n");break;case 'C':printf("60以下\n");default:printf("等级错误!\n");}D) switch (grade){case 'A':printf("85--100\n");break;case 'B':printf("60--84\n");break;case 'C':printf("60以下 \n");break;default:printf("等级错误!\n");}58、能够完成如下函数计算的程序段是__B____.┌ -1 x<0y= ┤ 0 x=0└ 1 x>0A) y=1; B) if (x>=0)if(x!=0) if(x>0) y=1;if(x>0) y=1; else y=0;else y=0; else y=-1;C) y=0; D) y=-1;if (x>=0) if (x>0) y=1;if (x>0) y=1; else y=0;else y=-1;59、有如下程序#include <>void main( ){ float x=,y;if(x< y=;else if (x< y=x;else y=;printf("%f\n",y);}该程序的输出结果是____C_____.A) B)C) D)60、以下程序的执行结果是___B_____.#include <>void main( ){ int x=1,y=0;switch (x){case 1:switch (y){case 0:printf("first\n");break; case 1:printf("second\n");break; }case 2:printf("third\n");}}A) first B) firstsecond thirdC) first D) secondthird61、以下程序的执行结果是____A____.#include <>void main( ){ int a,b,c,d,x;a=c=0;b=1;d=20;if (a) d=d-10;else if(!b)if (!c) x=15;else x=25;printf("d=%d\n",d);}A) d=20 B) d=10 C) d=15 D) 2562、有如下程序:#include <>void main( ){ int a=2,b=-1,c=2;if (a<b)if (b<0) c=0;else c++;printf("%d\n",c);}该程序的输出结果是___C_____.A) 0 B) 1 C) 2 D) 363、下列程序执行后的输出结果是____B____.#include <>void main( ){ int x,y=1,z;if ((z=y)<0) x=4;else if (y==0) x=5;else x=6;printf("%d,%d\n",x,y);}A) 4,1 B) 6,1 C) 5,0 D) 出错信息64、有如下程序#include <>void main( ){ int x=1,a=0,b=0;switch(x){case 0: b++;case 1: a++;case 2: a++;b++;}printf("a=%d,b=%d\n",a,b);}该程序的输出结果是______A____.A) a=2,b=1 B) a=1,b=1 C) a=1,b=0 D) a=2,b=265、下面程序的输出结果是____C_____.#include <>void main( ){ int a=-1,b=1,k;if ((++a<0) && (b--<=0))printf("%d %d\n",a,b);elseprintf("%d %d\n",b,a);}A) -1 1 B) 0 1 C) 1 0 D) 0 066、假定w、x、y、z、m均为int型变量,有如下程序段:w=1;x=2;y=3;z=4;m=(w<x)?w:x; m=(m<y)?m:y; m=(m<z)?m:z;则该程序段执行后,m的值是____D_____.A) 4 B) 3 C) 2 D) 167、以下程序的输出结果是___D______.main( ){ int a=100;if (a>100) printf("%d\n",a>100);else printf("%d\n",a<=100);}A) a<=100 B) 100 C) 0 D) 168、若执行下面的程序从键盘上输入9,则输出结果是.______B________#include <>void main( ){int n;scanf("%d",&n);if (n++<10) printf("%d\n",n);else printf("%d\n",n--);}A) 11 B) 10 C) 9 D) 869、以下程序输出结果是_____D_____.#include <> void main( ){ int m=4;if (++m>5) printf("%d\n",m--);else printf("%d\n",--m);}A) 7 B) 6 C) 5 D) 470、若执行下面的程序从键盘上输入5,则输出结果是.#include <>void main( ){int x;scanf("%d",&x);if (x++>5) printf("%d\n",x);else printf("%d\n",x--);}A) 7 B) 6 C) 5 D) 471、以下程序段运行结果是____A____.int x=1,y=1,z=-1;x+=y+=z;printf("%d\n",x<y?y:x);A) 1 B) 2 C) 4 D) 不确定的值72、有以下程序#include <>void main( ){ int a,b,c=246;a=c/100%9;b=(-1)&&(-1);printf("%d,%d\n",a,b);}输出结果是____A____.A) 2,1 B) 3,2 C) 4,3 D) 2,-173、运行下面程序时,若从键盘输入数据为"123",则输出结果是___C____.#include ""void main(){ int num,i,j,k,place;scanf("%d",&num);if (num>99)place=3;else if(num>9)place=2;elseplace=1;i=num/100;j=(num-i*100)/10;k=(num-i*100-j*10);switch (place){ case 3: printf("%d%d%d\n",k,j,i);break;case 2: printf("%d%d\n",k,j);break;case 1: printf("%d\n",k);}}A) 123 B) 1,2,3 C) 321 D) 3,2,174、执行下列程序后的输出结果是___D____.#include <>void main( ){ int k=4,a=3,b=2,c=1;printf("%d\n",k<a?k:c<b?c:a);}A) 4 B) 3 C) 2 D) 175、以下条件表达式中能完全等价于条件表达式x的是____B___.A) (x==0) B) (x!=0) C) (x==1) D) (x!=1)76、若运行下面程序时,给变量a输入15,则输出结果是___A___.#include <>void main( ){ int a,b;scanf("%d",&a);b=a>15?a+10:a-10;printf("%d\n",b) ;}A) 5 B) 25 C) 15 D) 1077、运行下面程序后,输出是___D___.#include <>void main( ){ int k=-3;if (k<=0) printf("****\n");else printf("####\n")}A) ####B) ****C) ####****D) 有语法错误不能通过编译78、执行下面程序的输出结果是____C____.#include <>void main( ){ int a=5,b=0,c=0;if (a=a+b) printf("****\n");else printf("####\n");}A) 有语法错误不能编译B) 能通过编译,但不能通过连接C) 输出 ****D) 输出 ####79、为了避免嵌套的if-else语句的二义性,C语言规定else总是与___C___组成配对关系.A) 缩排位置相同的ifB) 在其之前未配对的ifC) 在其之前尚未配对的最近的ifD) 同一行上的if80、设x 、y 、z 、t均为int型变量,则执行以下语句后,t的值为____C_____.x=y=z=1;t=++x || ++y && ++z;A) 不定值 B) 4 C) 1 D) 081、以下程序段____C______.x=-1;do{x=x*x;} while (!x);A)是死循环 B)循环执行两次C)循环执行一次 D)有语法错误82、对下面程序段描述正确的是___B____.int x=0,s=0;while (!x!=0) s+=++x;printf("%d",s);A) 运行程序段后输出0B) 运行程序段后输出1C) 程序段中的控制表达式是非法的D) 程序段循环无数次83、下面程序段的输出结果是____C____.x=3;do { y=x--;if (!y) {printf("*");continue;}printf("#");} while(x=2);A) ## B) ##* C) 死循环 D)输出错误信息84、下面程序的运行结果是____B____.#include<>void main( ){ int a=1,b=10;do{ b-=a;a++;} while(b--<0);printf("%d,%d\n",a,b);}A) 3,11 B) 2,8 C) 1,-1 D)4,985、下面程序段的运行结果是____B______.int n=0;while (n++<=2)printf("%d",n);A) 012 B) 123 C) 234 D) 错误信息86、下面程序段的运行结果是___D_____.int x=0,y=0;while (x<15) y++,x+=++y;printf("%d,%d",y,x);A) 20,7 B) 6,12 C) 20,8D)8,2087、下面程序的运行结果是___B_____.#include<>void main(){ int s=0,i=1;while (s<=10){ s=s+i*i;i++;}printf("%d",--i);}A) 4 B) 3 C) 5 D) 688、函数pi的功能是根据以下近似公式求π值:____C______(π*π)/6=1+1/(2*2)+1/(3*3)+..+1/(n*n)请填空,完成求π的功能。

C语言题库(194道)

C语言题库(194道)

C语言1、以下叙述不正确的是()。

——[单选题]A c程序中,语句之间必须用分号分隔。

B c程序中,多行语句可以写在一行上。

C c程序中,可以不必包含主函数。

D 一个c程序,可以由多个函数组成正确答案:C2、c语言规定,在一个源程序中,main函数的位置()——[单选题]A 必须在最开始B 必须在系统调用库函数的后面C 可以任意D 必须在最后正确答案:C3、以下叙述不正确的是()。

——[单选题]A main函数必须位于程序的最前面B c程序中,每行可以写多条语句C c语言本身不提供输入输出语句。

D 在对c语言程序进行编译的过程中,不能发现注释中的错误正确答案:A4、一个C程序的执行是从()——[单选题]A 本程序的main函数开始,到main函数结束B 本程序文件的第一个函数开始,到本程序文件的最后一个函数结束C 本程序文件的第一个函数开始,到本程序main函数结束D 本程序的main函数开始,到本程序文件的最后一个函数结束正确答案:A5、以下叙述不正确的是()——[单选题]A 一个C源程序必须包含一个main函数B 一个C源程序可由一个或多个函数组成C C程序的基本组成单位是函数D 在C程序中,注释说明只能位于一条语句的后正确答案:D6、以下叙述不正确的是()。

(2分)——[单选题]A 1. 若a和b类型相同,在计算了赋值表达式a=b后,b中的值将放入a中,且b中的值不变。

B 1. 当从键盘输入数据时,对于整型变量只能输入整型数值,对于实型变量只能输入实型数值。

C 1. 在C程序中,逗号运算符的优先级最低。

D 1. 在C程序中,MAX和max是两个不同的变量。

正确答案:B7、已知字母A的ASCII码为十进制数65,且c2为字符型,则执行语句:c2='A'+'6'-'3';printf("%c",c2);后,屏幕输出内容为()。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

C语言程序设计复习参考练习题语言程序设计复习参考练习题程序设计复习参考练习题,在对应的字母处标记“√”请在答案A、B、C、D中选出一个正确的答案中选出一个正确的答案,1. 一个C程序的执行是从【】。

A) 本程序的main函数开始,到main函数结束B) 本程序文件的第一个函数开始,到本程序文件的最后一个函数结束C) 本程序的main函数开始,到到本程序文件的最后一个函数结束D) 到本程序文件的第一个函数开始,到本程序的main函数结束2. 一个C语言程序是由【】。

A) 一个主程序和若干子程序组成B) 函数组成C) 若干过程组成D) 若干子程序组成3. C语言规定,在一个源程序中,main函数的位置【】。

A)必须在最开始B)必须在系统调用的库函数的后面C)可以在任何位置D)必须在最后4. 在C语言中,数字0X26是一个【】进制数。

A) 二B) 八C) 十D) 十六5. 设说明为int a[3]={1,2}, *p=a; 则*p与*(p+2)的值分别是【】。

A) 1和0B) 0和1 C) 1和2 D) 2和06. 设说明为int a=10; 执行语句a*=1+2+3; 后a的值是【】。

A) 15 B) 24 C) 33 D) 607. 为表示关系x≥y≥z,应使用C语言表达式【】。

A) (x>=y>=z) B) (x>=y)AND(y>=z) C) (x>=y)&&(y>=z) D) (x>=y)&(y>=z)8. 说明语句:int a[][3]={1,2,3,4,5,6,7,8,9}; 则a数组的行数为【】。

A) 不确定B) 1 C) 2 D) 39. 以下程序时,从键盘输入25,13,10<回车>,则输出结果是【】。

main() {int a1, a2, a3;scanf("%d,%d,%d", &a1, &a2, &a3);printf("a1+a2+a3=%d\n", a1+a2+a3);}A) a1+a2+a3=48 B) a1+a2+a3=25 C) a1+a2+a3=10 D) 不确定10. putchar函数可以向终端输出一个【】。

A) 整型变量值B) 实型变量值C) 字符串D) 字符或字符变量11. 执行下面程序,屏幕输出的值是【】int x;printf("%d\n", (x=3*5, x+5));A) 10 B) 15 C) 20 D) 512. 判断字符类型变量c是否为大写字母的正确表达式是【】。

A) 'A'<=c<='Z' B) (c>='A') & (c<='Z')C) (c>='A') && (c<='Z') D) ('A'<=c) AND ('Z'>=c)13. C语言规定:简单变量做实参时,它和对应形参之间的数据传递方式是【 】。

A) 地址传递B) 单向值传递C) 由实参传给形参,再由形参传回给实参D) 由用户指定传递方式14. 下面程序段的运行结果是【】。

char *s="abcde";s+=1;printf("%s\n", s);A) bcde B) abcde C) ab D) b15. 若有定义:int a[2][3]; 则以下对a数组元素的正确引用是【】。

A) *(a+1) B) *(a[1]+2) C) &a[0][0] D) a[1]+316. 若有定义:int s[4][6], t[6][4], (*p)[6]; 则以下正确的赋值语句是【】。

A) p=t; B) p=s[2]; C) p=s; D) p=t[3];17. 若有以下定义,则数组b占用内存的字节数是【】。

char b[]="C language";A) 14 B) 15 C) 8 D) 1118. 设说明为char str[6]={'a', 'b', '\0', 'c', 'd', '\0'}; 执行printf("%s", str); 后输出的结果是【】。

A) abcd B) abc C) ab D) ad19. 定义如下变量和数组,则语句for (i=0; i<3; i++) printf("%d ", x[i][2-i]); 的输出结果是【】。

int i;int x[3][3]={1, 2, 3, 4, 5, 6, 7, 8, 9};A) 1 5 9 B) 1 4 7 C) 3 5 7 D) 3 6 920. 有如下程序,运行后的输出结果是【】。

main() {int a=10, b=4, c=3;if(a<b) a=b;if(a<c) a=c;printf("%d,%d,%d\n", a, b, c);}A) 3,4,10 B) 4,4,3 C) 3,4,3 D) 10,4,321. 在C语言中,合法的字符常量是【】。

A) '\084' B) '\x43' C) 'ab' D) "\0"22. 若有定义和语句,则输出结果是【】。

int **pp, *p, a=10, b=20;pp=&p; p=&a; p=&b; printf("%d\n", *p, **pp);A) 10,20 B) 10,10 C) 20,10 D)20,2023. 若有以下定义和语句,则输出结果是【】。

char c1='b', c2='e';printf("%d,%c\n", c2-c1, c2-'a'+'A');A) 2,M B) 3,E C) 2,ED) 输出项与对应的格式控制不一致,输出结果不确定24. 在以下一组运算符中,优先级最高的运算符是【】。

A) <= B) = C) % D) &&25. 表达式(a=2,3), a+1 的值是【】。

A) 0 B) 2 C) 3 D) 426. 若执行printf("%d\n", strlen("a\n\"\x41")); 语句,其输出结果是【】。

A) 8 B) 7 C) 6 D) 427. 在循环语句的循环体中执行break语句,其作用是【】。

A) 跳出该循环体,提前结束循环B) 继续执行break语句之后的循环体各语句C) 结束本次循环,进行下次循环D) 终止程序运行28. 执行语句for(i=10; i>0; i--); 后,变量i的值为【】。

A) 10 B) 9 C) 0 D) 129. 如果定义一个整型变量int a; 使该变量字节不变,而正数值的表示范围扩大一倍的方式用【】。

A) signed B) long C) unsigned D) float30. 表达式10!=9的值是【】。

A) true B) 非零值C) 1 D) 031. 若int x=10; 则表达式x+(char)1/2.0 值的类型是【】。

A) int B) double C) float D) unsigned32. 以下不属于C语言关键字的是【】。

A) case B) byte C) do D) float33. C语言中,以下【】不是正确的常量。

A) 543210L B) 05078 C) -0x41 D) 1234534. 以下四组中都能正确作为C语言程序标识符的是【】组。

A) printf B) sort_1 C) pow D) book->namerow string_to_float string book.priceif PI 1_abc A#B35. 使下列程序段输出“123, 456, 78”,由键盘输入数据,正确的输入是【】。

int i, j, k;scanf("%d,%3d%d", &i, &j, &k);printf("%d,%d,%d\n", i, j, k);A) 12345678 B) 123, 456, 78 C) 123, 45678 D) 123, *4567836. 判断char类型的变量c1是否为数字字符的正确表达式为【】。

A) (c1>=0)&&(c1<=9) B) (c1>='0')&&(c1<='9')C) '0'<=c1<='9' D) (c1>='0')||(c1<='9')37. 若有语句int a=1,b=2,c=3; 则以下值为0的表达式是【】。

A) 'a'&&'b' B) a<=b C) (a>b)||(b<c) D) (!(a+b)==c&&a)38. C语言中的实数可以用多种形式表示,以下四种表示中,只有【】是错误的。

A) 23e+6 B) 13e-4 C) 0.3e1.2 D) .123439. 下面四个选项中,均是不合法的转义字符的选项是【】。

A) '\"' B) '\1011' C) '\011' D) '\abc''\\' '\' '\f' '\101''\xf' '\a' '\}' 'xlf'40. 以下符合C语言语法的赋值表达式是【】。

A) d=9+e=d+9 B) d=9+e, f=d+9 C) d=9+e, e++, d+9 D) d=9+e++=d+741. 若已定义:float aa=1234.5678; 则执行printf("%6.2f%d/n", aa, (int)(aa)); 则输出是【】。

相关文档
最新文档