当前位置:文档之家› C语言全部题目及答案

C语言全部题目及答案

C语言全部题目及答案
C语言全部题目及答案

C语言全部题目及答案 SANY GROUP system office room 【SANYUA16H-

C语言全部题目及答案

Exercise 1: Programming Environment and Basic Input/Output

1.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 as e2-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 program using the

following methods:

(a)Using four “printf” statements.

(b)Using one “printf” statement with no conversion specifier(i.e. no ‘%’).

(c)Using one “printf” statement with four conversion specifiers

3.(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?

Exercise 2: Data Types and Arithmetic Operations

1. 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? 6000

Annual interest rate percentage? 4.25

Balance after one year: 6255

ANSWER:

#include

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

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

int main()

{

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 structure

1.Write a C program that accepts a student’s numerical grade, converts the numerical 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 the user whether it is an odd or even number.

3.Write a program that reads in three integers and then determines and prints the largest in the group.

ANSWER:

#include

#include

{

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);

else

printf("%d is a odd number",a);

return 0;

}

Exercise 4: ‘switch’ statement and simple “while” repetition statement

1. Write a program that reads three integers an abbreviated date (for example: 26 12 94) and

that 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 integers from 2 to 30.

3. A large chemical company pays its sales staff on a commission basis. They receive £200

per week 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 t heir salary. Process one person’s figures at a time.

Enter sales in pounds (-1 to end): 5000.00

Salary is: 650.00

Enter sales in pounds (-1 to end): 00.00

Salary is: 200.00

Enter sales in pounds (-1 to end): 1088.89

Salary is: 298.00

Enter sales in pounds (-1 to end): -1

Optional:

4. A mail order company sells five different products whose retail prices are shown in the

following table:

Product Number Retail Price (in pounds)

1 2.98

2 4.50

3 9.98

4 4.49

5 6.87

Write a C program that reads in a series of pairs of numbers as follows:

(1). Product number

(2). Quantity sold for one day

Your 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:

Exercise 5: ‘for’ and ‘do … while” repetition statements

1. 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 +....

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 if the user enters ‘3’, then the program should calculate ? as being 4 - 4/3 + 4/5.

Nested repetition

3. 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 2*2= 4

3*1= 3 3*2= 6 3*3= 9

….

9*1= 9 9*2=18 9*3=27 9*4=36 9*5=45 9*6=54 9*7=63 9*8=72 9*9=81

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;

}

Exercise 6: Simple Functions

1.Write a C program that reads several numbers and uses the function

round_to_nearest to round each of these numbers to the nearest integer. The program 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 first pair, the

larger of the second pair and the larger of the third pair. Use a function to return the larger of each pair.

3. A car park charges a £2.00 minimum fee to park for up to 3 hours, and an additional

£0.50 for each hour or part hour in excess of three hours. The maximum charge for any given 24-hour period is £10.00. Assume that no car parks for more than 24 hours at a time.

Write a C program that will calculate and print the parking charges for each of 3 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:

Car Hours Charge

1 1.5 2.00

2 4.0 2.50

3 24.0 10.00

TOTAL 29.5 14.50

The program should use the function calculate_charges to determine the charge for each customer.

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);

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 Functions

1. 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, and 0 if it is not.

The 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 exponent

so 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 exponent

so 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 - 1 and the base case will be when exponent is 1 since : base1 = base.)

Exercise 08: Arrays

1.Write a program that reads ten numbers supplied by the user into a single subscripted 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 (2 rows)

(b) the whole array

3.Use a single-subscripted array to solve the following problem. Read in 20 numbers, each of which is between 10 and 100, 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

#include

int main()

{

#define NUMROWS 2

#define NUMCOLS 5

int number[NUMROWS][NUMCOLS];

int i,j,max1,max2,min1,min2;

for (i=0;i

{ printf("Please input 5 numbers with space between each other:\n"); for (j=0;j

scanf("%d",&number[i][j]);

}

max1=number[0][0];

min1=number[0][0];

max2=number[1][0];

min2=number[1][0];

for(j=0;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 Arrays

1.Write a program that enters 5 names of towns and their respective distance (an integer)

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, places these 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

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: Pointers

1. Write a program that reads 5 integers into an array, and then uses four different methods of

accessing the members of an array to print them out in reverse order.

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 (用一个函数)to find 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

int main()

{

int num1[5],i;

printf("Please input 5 numbers:\n");

for (i=0;i<5;i++)

scanf("%d",&num1[i]);

//the first way

printf("\nPrint them out in reverse order in the first way:\n");

for (i=4;i>=0;i--)

printf("%d",num1[i]);

//the second way

printf("\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 way

printf("\nPrint them out in reverse order in the third way:\n");

for(i=4;i>=0;i--)

printf("%d",*(num1+i));

//the fourth way

printf("\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;

c语言试题及答案

1、以下正确的说法是( B ) (A) 用户若需要调用标准库函数,调用前必须重新定义 (B) 用户可以重新定义标准库函数,若如此,该函数将失去原有含义 (C) 系统根本不允许用户重新定义标准库函数 (D) 用户若需调用标准库函数,调用前不必使用预编译命令将该函数所在文件包括到用户源文件中,系统自动去调 2、以下正确的函数声明形式是( 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); 3、以下正确的函数形式是( D ) (A) double fun(int x, int y) { z=x+y; return z;} (B) fun(int x,y) { int z; return z;} (C) fun(x,y) { int x,y; double z; z=x+y; return z;} (D) double fun(int x, int y) { double z; z=x+y; return z;} 4、以下正确的说法是( A ) 在C语言中 (A) 实参和与其对应的形参各占用独立的存储单元 (B) 实参和与其对应的形参共占用一个存储单元 (C) 只有当实参和与其对应的形参同名时才共占用存储单元 (D) 形参是虚拟的,不占用存储单元 5、若调用一个函数,且此函数中没有return语句,则正确的说法是( A ) 该函数 (A) 没有返回值 (B) 返回若干个系统默认值 (C) 能返回一个用户所希望的函数值 (D) 返回一个不确定的值 6、以下不正确的说法是( B ) C语言规定 (A) 实参可以是常量、变量和表达式 (B) 形参可以是常量、变量和表达式 (C) 实参可以为任意类型 (D) 形参应与其对应的实参类型一致 7、以下正确的说法是( C ) (A) 定义函数时,形参的类型说明可以放在函数体内 (B) return后边的值不能为表达式 (C) 如果函数值的类型与返回值类型不一致,以函数值类型为准 (D) 如果形参与实参的类型不一致,以实参类型为准 8、C语言规定,简单变量做实参时,它和对应形参之间的数据传递方式是( B ) (A) 地址传递 (B) 单向值传递 (C) 由实参传给形参,再由形参传回给实参 (D) 由用户指定传递方式

C语言试卷及答案

一、选择题(每题 1 分,共 20 分) 1. C 语言程序的三种基本结构是顺序结构、选择结构和结构。 A、循环 B、递归 C、转移 D、嵌套 2. 下列标识符中,合法的是_______ 。 A) unsigned B) 5ab C) INT# D)_num2 3. 若float x ;x = 10/4 ;x的值是。 A、2.5 B、2.0 C、3 D、 2 4. 表达式!x 等价于。 A、x==0 B、x==1 C、x != 0 D、x != 1 5. 算术运算符、赋值运算符和关系运算符的运算优先级按从高到低的顺序依次为。 A、算术运算、赋值运算、关系运算 B、关系运算、赋值运算、算术运算 C、算术运算、关系运算、赋值运算 D、关系运算、算术运算、赋值运算 6. 能将高级语言编写的源程序转换为目标程序的是。 A、链接程序 B、解释程序 C、编译程序 D、编辑程序 7. 下列语句定义pf为指向float类型变量f的指针,是正确的。 A、float f, *pf = f; B、float f, *pf = &f; C、float *pf = &f, f; D、float f, pf = f; 8. 一个C程序的执行是从。 A、本程序的main函数开始,到main函数结束 B、本程序文件的第一个函数开始,到本程序文件的最后一个函数结束 C、本程序的main函数开始,到本程序文件的最后一个函数结束 D、本程序文件的第一个函数开始,到本程序main函数结束 9. 能正确表示“当x的取值在[1,10]或[[200,210]范围内为真,否则为假”的表达式是________。 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) 10. 对两个数组a和b进行如下初始化 char a[]=“ABCDEF”;char b[]={ …A?,?B?,?C?,?D?,?E?,?F?}; 则以下叙述正确的是。 A、a和b数组完全相同 B、a和b长度相同 C、a和b中都存放字符串 D、a数组比b数组长度长 11. 是不正确的字符常量。 A、'\n' B、'1' C、"a" D、'\101' 12. 若变量已正确定义,语句“if(a>b) k=0; else k=1;”和等价。 A、k=(a>b)?1:0; B、k=a>b; C、k=a<=b; D、a<=b ? 0 : 1; 13. 设变量定义为“int x, *p=&x;”,则&*p相当于。 A、p B、*p C、x D、*&x 14. 有两个字符数组a、b,则以下正确的输入语句是。 A)gets(a,b); B) scanf(“%s%s”,a,b); C) scanf(“%s%s”,&a,&b); D) gets(“a”),gets(“b”); 15. C语言规定,简单变量做实参时,它和对应形参之间的数据传递方式是。 A、地址传递 B、单向值传递

C语言全部题目及答案

C语言全部题目及答案 SANY GROUP system office room 【SANYUA16H-

C语言全部题目及答案 Exercise 1: Programming Environment and Basic Input/Output 1.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 as e2-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 program using the following methods: (a)Using four “printf” statements. (b)Using one “printf” statement with no conversion specifier(i.e. no ‘%’). (c)Using one “printf” statement with four conversion specifiers 3.(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?

c语言期中考试试题及答案

《C语言程序设计》期中考试试卷 课程编号:03402513试卷类型:A卷考试形式:笔试考试日期: 注意事项:1.请将试卷最后一页的答题纸撕下,将答案填写在其中;2.交卷时请确认答题纸是否按要求写好姓名等信息并与试题一起上交;3.不准携带任何书籍、资料、纸张等。4.草稿纸用试卷的背面。 一、单项选择题(1空1分,共20分) 1、C语言程序的基本结构是(【1】) 。 【1】A) 函数B) 语句C) 字符D) 程序行 2、一个C程序的执行是(【2】) 。 【2】A) 从本程序的主函数开始,到本程序的主函数结束 B)从本程序的第一个函数开始,到本程序的最后一个函数结束 C) 从本程序的主函数开始,到本程序的最后一个函数结束 D)从本程序的第一个函数开始,到本程序的主函数结束 3、下列四个叙述中,错误的是(【3】) 。 【3】A) 一个C源程序必须有且只能有一个主函数 B) 一个C源程序可以含一个或多个子函数 C) 在C源程序中注释说明必须位于语句之后 D) C源程序的基本结构是函数 4、下面不属于C语言保留字的是(【4】) 。 【4】A) short B) ELSE C) extern D) for 5、下列四个叙述中,正确的是(【5】) 。 【5】A) 库函数也是C语言本身的组成部分 B) C语言中的输入输出操作是由相应语句完成的 C) 库函数是C编译系统提供的功能函数 D) 标题文件(头文件)可以在程序的函数内部调用 6、下列四组数据类型中,C语言允许的一组是(【6】)。 【6】A) 整型、实型、逻辑型B) 整型、实型、字符型 C) 整型、双精度型、布尔型D) 整型、实型、复型 7、在C语言中不同数据类型的的长度是(【7】)。 【7】A) 固定的B) 由用户自己定义的 C) 任意的D) 与机器字长有关

c语言试题及答案 ()

第1章 C语言概述习题 1. 单项选择题 (1) C 语言是在 B 语言的基础上产生的。 A. 回车符 B. 冒号 C. 逗号 D. 分号 (2) 在 C 语言中,每个语句必须以 D 结束。 A. 回车符 B. 冒号 C. 逗号 D. 分号 (3) 标识符和关键字间,要用 C 隔开。 A. 回车符 B. 冒号 C. 空格 D. 分号 (4) 用 C 语言编写的源文件经过编译,若没有产生编译错误,则系统将( B )。 A. 生成可执行目标文件 B. 生成目标文件 C. 输出运行结果 D.自动保存源文件 (5) 下列说法中正确的是( B )。 A. 由于 C 源程序是高级语言程序,因此一定要在 TC 软件中输入 B. 由 C 源程序是字符流组成,因此可以作为文本文件在任何文本编辑的软件中输入 C. 由于C 程序是高级语言程序,因此输入后即可执行 D. 由于 C 程序是高级语言程序,因此它由命令组成 (6) 下列说法中正确的是( A )。 A. C 语言程序由主函数和 0 个或多个函数组成 B. C 语言程序由

主程序和子程序组成 C. C 语言程序由子程序组成 D. C 语言程序由过程组成 (7) 下列说法中错误的是( D )。 A. 主函数可以分为两个部分:主函数说明部分和主函数体 B. 主函数可以调用任何非主函数的其他函数 C. 任何非主函数可以调用其他任何非主函数 D. 程序可以从任何非主函数开始执行 2. 填空题 (1) C 语言只有 37 个关键字和 9 种控制语句。 (2) C 语言是一种“中级语言”,既具有高级语言的特点又具有低级语言的特点;既适合于开发系统软件又适合于编写应用程序。 (3) 每个源程序有且只有一个主函数,系统总是从该函数开始执行C语言程序。 (4) 在 C 语言程序中允许出现的字符集是 ASCII码字符集。 (5) C 语言的程序中有特殊含义的英语单词称为保留字。 (6) C 语言标识符的长度是前 8 位有效。 (7) C 语言中,标识符的定义规则是以字母或下划线为开头。 (8) C 语言程序的注释可以出现在程序中的任何地方,它总是以 /* 符号作为开始标记,以 */ 符号作为结束标记。

C语言试题及答案

一、单项选择题 1. 软件危机具有下列表现( d )。 I. 对软件开发成本估计不准确II. 软件产品的质量往往靠不住 III. 软件常常不可维护IV. 软件成本逐年上升 A. I、II和III B. I、III和IV C. II、III和IV D. 以上都正确 2. 软件生命周期一般都被划分为若干个独立的阶段,其中占用精力和费用最多的阶段往往是( A )。 A. 运行和维护阶段 B. 设计阶段 C. 代码实现阶段 D. 测试阶段 3. 下列属于软件的特点的是(D )。 A. 软件是一种逻辑实体,具有抽象性 ~ B. 软件在使用过程中没有磨损、老化的问题 C. 软件不同于一般程序,它的一个显著特点是规模庞大,复杂程度高 D. 以上都正确 4. 软件工程的出现是由于(D )。 A. 软件危机的出现 B. 计算机硬件技术的发展 C. 软件社会化的需要 D. 计算机软件技术的发展 5. 软件开发技术不包含( d )。 A. 软件开发方法学 B. 软件工程环境 C. 软件工具 D. 软件质量度度量 6. 软件工程的课程特点( D )。 【 I. 学科理论及其知识应用的多维性 II. 工程化 III. 浓厚的方法学色彩 IV. 实践性、指导性强 A. I、II和III B. I、III和IV C. II、III和IV D. 以上都正确 7. 下列属于应用软件的是( b )。 I. 计算机辅助教学软件II. 软件测试工具 III. 办公自动化软件IV. 工程与科学计算软件

A. I、II和III B. I、III和IV C. II、III和IV D. 以上都正确 8. 需求分析阶段最重要的技术文档是( b )。 - A. 设计说明书 B. 需求规格说明书 C. 可行性分析报告 D. 用户手册 9. 以下关于数据流图的说法错误的是( c )。 A. 数据流图舍去了具体的物质,只剩下数据的流动、加工处理和存储 B. 数据流图是用作结构化分析的一种工具 C. 传统的数据流图中主要由加工、数据源点/终点、数据流、控制流、数据存储组成 D. 数据流图的绘制采用自上向下、逐层分解的方法 10. 数据字典是软件需求分析阶段的最重要工具之一,其最基本的功能是( c )。 A. 数据库设计 B. 数据通信 C. 数据定义 D. 数据维护 11. 需求分析阶段的研究对象是( b )。 ¥ A. 系统分析员要求 B. 用户要求 C. 软硬件要求 D. 系统要求 12. 结构化方法的基本原则是( b )。 A. 模块化 B. 抽象与分解 C. 信息隐蔽 D. 逐步求精 13. 耦合度最高的是(b)耦合。 A. 环境 B. 内容 C. 控制 D. 数据 14. 内聚程度较低的是( a )内聚。 A. 偶然 B. 通讯 C. 顺序 D. 时间 15. 对一个程序来说,组成系统的模块数目( b ),则开发成本越小。 A. 越多 B. 越少 C. 顺序 D. 时间> 16. 画软件结构图时应注意调用关系只能是(B )。 A. 从下到上 B. 从上到下 C. 从左到右 D. 从右到左 17. 程序流程图中的箭头代表( b )。 A. 数据流 B. 控制流 C. 顺序流 D. 调用 18. 软件测试是软件质量保证的重要手段,下述( B )是软件测试的最基础环节。

C语言试题及答案06612

大学C语言考试题库 第1章C语言概述习题 1. 单项选择题 (1) C 语言是在 B 语言的基础上产生的。 A. A B. B C. D D. E (2) 在C 语言中,每个语句必须以 D 结束。 A. 回车符 B. 冒号 C. 逗号 D. 分号 (3) 标识符和关键字间,要用 C 隔开。 A. 回车符 B. 冒号 C. 空格 D. 分号 (4) 用C 语言编写的源文件经过编译,若没有产生编译错误,则系统将( B )。 A. 生成可执行目标文件 B. 生成目标文件 C. 输出运行结果 D.自动保存源文件 (5) 下列说法中正确的是( B )。 A. 由于C 源程序是高级语言程序,因此一定要在TC 软件中输入 B. 由C 源程序是字符流组成,因此可以作为文本文件在任何文本编辑的软件中输入 C. 由于C 程序是高级语言程序,因此输入后即可执行 D. 由于C 程序是高级语言程序,因此它由命令组成 (6) 下列说法中正确的是( A )。 A. C 语言程序由主函数和0 个或多个函数组成 B. C 语言程序由主程序和子程序组成 C. C 语言程序由子程序组成 D. C 语言程序由过程组成 (7) 下列说法中错误的是( D )。 A. 主函数可以分为两个部分:主函数说明部分和主函数体 B. 主函数可以调用任何非主函数的其他函数 C. 任何非主函数可以调用其他任何非主函数 D. 程序可以从任何非主函数开始执行 2. 填空题 (1) C 语言只有32 个关键字和9 种控制语句。

(2) C 语言是一种“中级语言”,既具有高级语言的特点又具有低级语言的特点;既适合于开发系统软件又适合于编写应用程序。 (3) 每个源程序有且只有一个主函数,系统总是从该函数开始执行C语言程序。 (4) 在C 语言程序中允许出现的字符集是ASCII码字符集。 (5) C 语言的程序中有特殊含义的英语单词称为保留字。 (6) C 语言标识符的长度是前8 位有效。 (7) C 语言中,标识符的定义规则是以字母或下划线为开头。 (8) C 语言程序的注释可以出现在程序中的任何地方,它总是以/* 符号作为开始标记,以*/ 符号作为结束标记。 第2章数据类型运算符和表达式习题 1. 单项选择题 (1) 以下选项中,正确的C 语言整型常量是 D 。 A. 32L B. 510000 C. -1.00 D. 567 (2) 以下选项中, D 是不正确的C 语言字符型常量。 A. 'a' B. '\x41' C. '\101' D. "a" (3) 在C 语言中,字符型数据在计算机内存中,以字符的 C 形式存储。 A. 原码 B. 反码 C. ASCII 码 D. BCD码 (4) 字符串的结束标志是 C 。 A. 0 B. '0' C. '\0' D. "0" (5) 算术运算符、赋值运算符和关系运算符的运算优先级按从高到低依次为 B 。 A. 算术运算、赋值运算、关系运算 B. 算术运算、关系运算、赋值运算 C. 关系运算、赋值运算、算术运算 D. 关系运算、算术运算、赋值运算 (6) 逻辑运算符中,运算优先级按从高到低依次为 D 。 A. &&,!,|| B. ||,&&,! C. &&,||,! D. !,&&,|| (7) 表达式!x||a==b 等效于 D 。 A. !((x||a)==b) B. !(x||y)==b C. !(x||(a==b)) D. (!x)||(a==b) (8) 设整型变量m,n,a,b,c,d 均为1,执行(m=a>b)&&(n=c>d)后, m,n 的值是 A 。 A. 0,0 B. 0,1 C. 1,0 D. 1,1

c语言试题及答案

c语言试题及答案 Company Document number:WTUT-WT88Y-W8BBGB-BWYTT-19998

1、以下正确的说法是(B) (A)用户若需要调用标准库函数,调用前必须重新定义 (B)用户可以重新定义标准库函数,若如此,该函数将失去原有含义 (C)系统根本不允许用户重新定义标准库函数 (D)用户若需调用标准库函数,调用前不必使用预编译命令将该函数所在文件包括到用户源文件中,系统自动去调 2、以下正确的函数声明形式是(A) (A)doublefun(intx,inty) (B)doublefun(intx;inty) (C)doublefun(intx,inty); (D)doublefun(intx,y); 3、以下正确的函数形式是(D) (A)doublefun(intx,inty){z=x+y;returnz;} (B)fun(intx,y){intz;returnz;} (C)fun(x,y){intx,y;doublez;z=x+y;returnz;} (D)doublefun(intx,inty){doublez;z=x+y;returnz;} 4、以下正确的说法是(A ) 在C语言中 (A)实参和与其对应的形参各占用独立的存储单元 (B)实参和与其对应的形参共占用一个存储单元

(C)只有当实参和与其对应的形参同名时才共占用存储单元 (D)形参是虚拟的,不占用存储单元 5、若调用一个函数,且此函数中没有return语句,则正确的说法是(A) 该函数 (A)没有返回值 (B)返回若干个系统默认值 (C)能返回一个用户所希望的函数值 (D)返回一个不确定的值 6、以下不正确的说法是(B) C语言规定 (A)实参可以是常量、变量和表达式 (B)形参可以是常量、变量和表达式 (C)实参可以为任意类型 (D)形参应与其对应的实参类型一致 7、以下正确的说法是(C) (A)定义函数时,形参的类型说明可以放在函数体内 (B)return后边的值不能为表达式 (C)如果函数值的类型与返回值类型不一致,以函数值类型为准 (D)如果形参与实参的类型不一致,以实参类型为准

C语言试题及答案

第1章C语言概述习题1. 单项选择题 (1) C 语言是在 B 语言的基础上产生的。 A. 回车符 B. 冒号 C. 逗号 D. 分号 (2) 在 C 语言中,每个语句必须以 D 结束。 A. 回车符 B. 冒号 C. 逗号 D. 分号 (3) 标识符和关键字间,要用 C 隔开。 A. 回车符 B. 冒号 C. 空格 D. 分号 (4) 用 C 语言编写的源文件经过编译,若没有产生编译错误,则系统将( B )。 A. 生成可执行目标文件 B. 生成目标文件 C. 输出运行结果 D.自动保存源文件 (5) 下列说法中正确的是( B )。 A. 由于 C 源程序是高级语言程序,因此一定要在 TC 软件中输入 B. 由 C 源程序是字符流组成,因此可以作为文本文件在任何文本编辑的软件中输入 C. 由于C 程序是高级语言程序,因此输入后即可执行 D. 由于 C 程序是高级语言程序,因此它由命令组成 (6) 下列说法中正确的是( A )。 A. C 语言程序由主函数和 0 个或多个函数组成 B. C 语言程序由主程序和子程序组成

C. C 语言程序由子程序组成 D. C 语言程序由过程组成 (7) 下列说法中错误的是( D )。 A. 主函数可以分为两个部分:主函数说明部分和主函数体 B. 主函数可以调用任何非主函数的其他函数 C. 任何非主函数可以调用其他任何非主函数 D. 程序可以从任何非主函数开始执行 2. 填空题 (1) C 语言只有 37 个关键字和 9 种控制语句。 (2) C 语言是一种“中级语言”,既具有高级语言的特点又具有低级语言的特点;既适合于开发系统软件又适合于编写应用程序。 (3) 每个源程序有且只有一个主函数,系统总是从该函数开始执行C语言程序。 (4) 在 C 语言程序中允许出现的字符集是 ASCII码字符集。 (5) C 语言的程序中有特殊含义的英语单词称为保留字。 (6) C 语言标识符的长度是前 8 位有效。 (7) C 语言中,标识符的定义规则是以字母或下划线为开头。 (8) C 语言程序的注释可以出现在程序中的任何地方,它总是以/* 符号作为开始标记,以 */ 符号作为结束标记。

c语言经典编程试题12例(带答案)

1、输入一个整数,判断该整数是不是素数。 解题思路: 什么是素数?大于1且除了1和它本身之外,没有可以将它除尽的数,这样的数便是素数。判断一个整数是不是素数,首先定义被除数从2开始,当除到比这个数小1的数时,依然没有除尽,则这个数就是素数,否则则不是素数。 #include void main() { int num,i,leap=0; int con=1; while(1) { printf("请输入一个大于0的整数: "); scanf("%d",&num); for(i=2;i1) printf("整数%d是一个素数。\n",num); else { leap=0; printf("整数%d不是一个素数。\n",num); } printf("\n是否继续?\n1、继续\n2、退出\n"); scanf("%d",&con); if(con!=1) break; } } 2、求100以内自然数中最大的能被17整除的数。 3、解题思路: (1)定义变量从0开始,且定义一个中间变量temp,如果被定义的变量可以除尽17,则把这个数赋值给temp,跳出循环后,temp的值便是100以内能被17整除的最大数。#include void main() { int i,temp,leap; for(i=0;i<=100;i++)

{ if(i%17==0) temp=i; } leap=temp/17; printf("100之内自然数中最大的能被17整除的数是: %d\n",temp); printf("被除数是%d\n",leap);} (2)定义变量从100开始,依次减一,如果遇到能整除17的数,则这个数便是100以内能整除17的最大数。 #include void main() { int i,temp,leap; for(i=100;i>=0;i--) if(i%17==0) break; printf("100之内自然数中最大的能被17整除的数是: %d\n",i); printf("被除数是%d\n",i/17); } 4、已知a,b,c都是1位整数,求当三位整数abc,cba的和为1333时a、b、c 的值。 解题思路: 利用三重for循环,当abc与cba的和为1333时便输出此时a,b,c的值。 #include void main() { int a,b,c; for(a=0;a<10;a++) for(b=0;b<10;b++) for(c=0;c<10;c++) if(a*100+b*10+c+a+b*10+c*100==1333) printf("a,b,c的值为:\na=%d\nb=%d\nc=%d\n",a,b,c); } 5、计算200~400之内不能被3整除的整数之和。 解题思路: 一个数能不能被3整除,则看它除以3之后的余数是否为0。如果为0,则能被整除,否则不能被整除。 #include void main() { int i,sum=0; for(i=200;i<=400;i++) if(i%3!=0) sum+=i;

C语言试题-10(含答案)

C语言试题 2019.03 一、单项选择题(共30分,每题1分) 1.在PC机中,‘\n’在内存占用的字节数是() A.1 B.2 C. 3 D.4 2.字符串“ABC”在内存占用的字节数是() A.3 B. 4 C.6 D.8 3.在C语言中,合法的长整型常数是() A.0L B.4962710 C.0.054838743 D.2.1869 e10 4.执行语句“x=(a=3,b=a--)”后,x,a,b的值依次是() A.3,3,2 B.3,2,2 C.3,2,3 D.2,3,2 5.设有语句int a=3;,则执行了语句a+=a-=a*a后,变量a的值是() A.3 B.0 C.9 D.-12 6.设int k=32767;执行k=k+1;后k值为() A.32768 B.-32768 C.0 D.-1 7.下列正确的标识符是() A.hot_do B.a+b C.test! D.%y 8.设int a=5,使b不为2的表达式是() A.b=6-(--a) B.b=a%2 C.b=a/2 D.b=a>3?2:1 9.执行x=(6*7%8+9)/5;后,x的值为() A.1 B.2 C.3 D.4 10.执行语句x=(a=3,b=a--)后,x,a,b的值依次为() A.3,2,3 B.2,3,2 C.3,3,2 D.3,2,2 11.设a=-3;执行(a>0)?a:-a;后,a的值为() A.3 B.1 C.0 D.-3 12.设所有变量均为整型,则表达式(a=2,b=5,b++,a+b)的值为() A.7 B.8 C.9 D.2 13.下面正确的字符常量是() A.”c” B.’\\’’ C.’W’ D. ‘’ 14.若有代数式3ae/bc,则不正确的c语言表达式是() A.a/b/c*e*3 B.3*a*e/b/c C.3*a*e/b*c D.a*e/c/c*3 15.在C语言中,要求运算数必须是整型的运算符是() A./ B.++ C.!= D.% 16.若有说明语句:char c=’\72’;则变量c ( ) A.包含1个字符 B.包含2个字符 C.包含3个字符 D.说明不合法,c值不确定 17.sizeof (float)是() A.一个双精度型表达式 B.一个整型表达式 C.一种函数调用 D 一个不合法的表达式 18.设变量a 是整型,f是实型,i是双精度型,则表达式10+’a’+i*f值的数据类型是()A.int B.folat C.double D.不确定 19.若有定义int a[10],*p=a;,则p+5表示() A.元素a[5]的地址 B.元素a[5]的值 C.元素a[6]的地址 D.元素a[6]的值

c语言试题和答案

《C语言》课程综合复习资料 一、单选题 1. 在C语言中,字符型数据在内存中的存储形式是 A)原码 B)补码 C)反码 D)ASCII码 2. 在C语言中,十进制数47可等价地表示为 A) 2f B) 02f C) 57 D) 057 3. 设有定义:int x=12,n=5; 则表达式 x%=(n%2) 的值为 A) 0 B) 1 C) 2 D) 3 4. 设有定义语句:char str[][20]={,"Beijing","中国石油大学"},*p=str; 则printf("%d\n",strlen(p+20)); 输出结果是 A)10 B) 6 C) 0 D) 20 5. 已定义以下函数: fun(int *p) { return *p; } 该函数的返回值是 A)不确定的值 B)形参p所指存储单元中的值 C)形参p中存放的值 D)形参p的地址值 6. C语言中,函数返回值的类型是由 A)return语句中的表达式类型决定 B)调用函数的主调函数类型决定 C)调用函数时的临时类型决定 D)定义函数时所指定的函数类型决定 7. 有以下函数定义: void fun( int n , double x ) { …… } 若以下选项中的变量都已正确定义并赋值,则对函数fun的正确调用语句是 A) fun( int y , double m ); B) k=fun( 10 , 12.5 ); C) fun( 10 , 12.5 ); D) void fun( 10 , 12.5 ); 8. 以下选项中不能正确赋值的是 A) char b[]={′H′,′e′,′l′,′l′,′o′,′!′}; B) char b[10];b="Hello!";

C语言试卷(含答案)

一、单项选择题(每小题2分,共40分) 1、sizeof(float)是() A. 一个双精度型表达式 B. 一个整型表达式 C. 一种函数调用 D. 一个不合法的表达式 2、设i是int型变量,f是float型变量,用下面的语句给这两个变量输入值: scanf("i=%d,f=%f",&i,&f); 为了把100和分别赋给i和f,则正确的输入为()。 A. 100 B. i=100,f=765.12 C. 100<回车> D. x=100y= 3、#include<> voidmain() { inta=3,b=2,c=1; intx=10,y=20; if(a voidmain() { intnum=0; while(num<=2){ num++; printf("%d",num); } } 输出结果是()。 A. 123 B. 012 C. 23 D. 12 8、下面的C语言代码段的输出结果是()。 intj; for(j=1;j<10;j+=2) printf("%d",j); A. 123456789 B. 2468 C. 13579 D. 12468 9、在C语言中,表达式:10!=9的值是()。 A. true B. 非零值 C. 0 D. 1 10、分析下面的C代码段: charstr1[15]="SeaView";

c语言期末考试题及其答案

c语言期末考试题及其答案

建瓯市技工学校2015-2016年第二期 《C语言》试题 姓名:班级: 成绩: 一选择题(每小题2分,共50分) 1.C语言源程序的基本单位是()。 A 过程 B 函数 C 子程序 D 标识符 2.下列程序的输出结果是()。 main( ) { int a=7,b=5; printf("%d\n",b=b/a); } A 5 B 1 C 0 D不确定值 3.假设变量a,b均为整型,表达式(a=5,b=2,a>b?a++:b++,a+b)的值是()。 A 7 B 8 C 9 D 2 4.设a为int型变量,执行下列赋值语句后,a的取值分别是()。 a=125.534; a=(int)125.521%4; a=5<<2; A 125,31,1 B 125,1,20 C 125,31,20 D 125.534,2,20 5.设有如下程序段,下面描述中正确的是()。 int k=10; while(k=0) k=k-1; A 循环执行一次 B循环是无限循环 C循环体语句一次也不执 行 D循环体语句执行一次 6.以下程序的输出结果为()。 int i; void prt( )

{ int i=010,j=10; printf("%d,%d\n",i++,j--); } 17.设a为int型变量,执行下列赋值语句后,a的取值分别是()。 a=125.534;a=20.0/3;a=(int)125.521%4;a=5<<2; A 125,6,31,1 B 125,6,1,20 C 125,6.666666,31,20 D 125.534,6.666666,2,20 18.设i和k都是int类型,则for循环语句()。 for(i=0,k=-1;k=1;i++,k++) printf("****\n"); A 循环结束的条件不合法 B 循环体一次也不执行 C 循环体只执行 一次 D 是无限循环 19.以下程序的输出结果为()。 main( ) { char c; int i; for(i=65;i<68;i++) { c=i+32; switch(c) { case 'a':case 'b':case 'c':printf("%c,",c);break; default:printf("end");} } } A a,b,c,end B a,a,a,end C a,a,a, D a,b,c, 20.函数调用语句:fseek(fp,-10L,2);的含义是()。 A 将文件位置指针从文件末尾处向文件头的方向移动10个字节 B 将文件位置指针从当前位置向文件头的方向移动10个字节

一c语言试题及答案

一、单项选择题(20分,每题2分) 1.程序段 int *p,a; p=&a; a=10; printf("%d",p); 的输出应为: A)10 B)0 C)不能确定 D)语法错误 2.C语言规定,简单变量作为实参时,他和对应形参之间的数据传递方式是: A)单向值传递 B) 地址传递 C) 相互传递 D) 由用户指定方式3.以下语句或语句组中,能正确进行字符串赋值的是。 A)char *sp;*sp="right!"; B)char s[10];s="right!"; C)char s[10];*s="right!"; D)char *sp="right!"; 4.for(i=0;i<10;i++) if(i〈=5) break; 则循环结束后i的值为 A)0 B)1 C)5 D)10 5.有以下程序 main() { int m,n,p; scanf("m=%dn=%dp=%d",&m,&n,&p); printf("%d%d%d\n",m,n,p); }

若想从键盘上输入数据,使变量m中的值为123,n中的值为456,p中的值为789,则正确的输入是。A)m=123n=456p=789 B) m=123 n=456 p=789 C)m=123,n=456,p=789 D)123 456 789 6.C语言中,最基本的数据类型包括: A)整型、实型、逻辑型 B)整型、字符型、数组 C)整型、实型、字符型 D)整型、实型、结构体 7.以下说法正确的是 A) C程序总是从第一个定义的函数开始执行 B) 在C程序中,要调用的函数必须在main()函数中定义 C) C程序总是从main()函数开始执行 D) C程序的main()函数必须放在程序的开始部分 8.程序段 int *p, a=1; p=&a; *p=10; a的值为: A) 1 B) 10 C) 不能确定 D) 11 9.以下定义语句中,错误的是 A) int a[]={1,2}; B) char *a[3]; C) char s[10]="test"; D) int n=5,a[n]; 10.假定int类型变量占用两个字节,有定义:int x[10]={0,2,4};,则数组x在内存中所占字节数是 A) 3 B) 6 C) 10 D) 20 二、填空题(30分,每空2分) 1.已知字符A的ACSII码值为65,以下语句的输出结果是 (1) 。

C语言试题及答案

C语言试题及答案 一、问答题 1、局部变量能否和全局变量重名? 答:能,局部会屏蔽全局。要用全局变量,需要使用 \ 局部变量可以与全局变量同名,在函数内引用这个变量时,会用到同名的局部变量,而不会用到全局变量。对于有些编译器而言,在同一个函数内可以定义多个同名的局部变量,比如在两个循环体内都定义一个同名的局部变量,而那个局部变量的作用域就在那个循环体内。 2、如何引用一个已经定义过的全局变量? 答:extern 可以用引用头文件的方式,也可以用extern关键字,如果用引用头文件方式来引用某个在头文件中声明的全局变理,假定你将那个变写错了,那么在编译期间会报错,如果你用extern方式引用时,假定你犯了同样的错误,那么在编译期间不会报错,而在连接期间报错。 3、全局变量可不可以定义在可被多个.C文件包含的头文件中?为什么? 答:可以,在不同的C文件中以static形式来声明同名全局变量。

可以在不同的C文件中声明同名的全局变量,前提是其中只 能有一个C文件中对此变量赋初值,此时连接不会出错 4、语句for( ;1 ;)有什么问题?它是什么意思? 答:和while(1)相同。 5、do??while和while??do有什么区别? 答:前一个循环一遍再判断,后一个判断以后再循环 6、请写出下列代码的输出内容 #include main() { int a,b,c,d; a=10; b=a++; c=++a; d=10*a++; printf( \,c,d:%d,%d,%d \,b,c,d); return 0; } 答:10,12,120 7、static全局变量与普通的全局变量有什么区别?static 局部变量和普通局部变量有什么区别?static函数与普通函数有 什么区别? 全局变量(外部变量)的说明之前再冠以static 就构成了 静态的全局变 量。全局变量本身就是静态存储方式,静态全局变量当 然也是静态存储方式。

c语言试题及答案

一、单选题 1.在C语言中,下列类型属于构造类型的是( D ) A.整型 B.字符型 C.实型 D.数组类型 2.下列字符串不是标识符的是( D ) A. sum B. Average C. Day_night D. M.D.JOHN 3. 在C语言中,回车换行符是( A ) A. n B. t C. v D. b 4. 在C语言中,语句和数据定义是用( C )作为结束标记的A.句号 B.逗号 C.分号 D.括号 5. 设有如下定义: int x=10,y=5,z; 则语句printf(“%dn”,z=(x+=y,x/y)); 的输出结果是( C ) A.0 B.1 C.3 D.4 6. 10.以下程序的输出结果是( B ) main( ) {char c1=’8’,c2=’2’; printf(“%c,%c,%d,%dn”,c1,c2,c1-c2,c1+c2); }

A.因输出格式不合法,输出出错信息 B.8,2,6,106 C.8,2,6,10 D.8,2,5,9 7.两次运行下面的程序,如果从键盘上分别输入6和4,则输出结果是( A )main( ) {int x; scanf(“%d”,&x); if(x++>5) printf(“%dn”,x); else printf(“%dn”,x--); } A.7和5 B.7和4 C.6和4 8.表达式(int)2.1416的值时( A ) A. 2 B. 2.1 C. 0 D. 3 9.下列运算符优先级最高的是( B ) A. > B. + C. && D. != 10. C语言容许函数值类型缺省定义,此时该函数值隐含的类型时( B ) A. float型 B. Int型 C. Long 型 D. Double型 11、C程序的基本构成单位是( C) A、子程序 B、过程 C、函数 D、文件 12、C语言中要求操作数都为整型数据的算术符是(C )

C语言考试题及答案

一、单项选择题:(10分,每题2分) 1.char *p[10];该语句声明了一个:。 A)指向含有10个元素的一维字符型数组的指针变量p B)指向长度不超过10的字符串的指针变量p C)有10个元素的指针数组p,每个元素可以指向一个字符串 D) 有10个元素的指针数组p,每个元素存放一个字符串 2.若int x;且有下面的程序片断,则输出结果为:。 for (x=3; x<6; x++) { printf((x%2) ? "##%d" : "**%d\n", x); } A) ##3B) **3C) **3D)##3**4 **4 ##4 ##4**5 ##5 ##5 **5 3.在while(!x)语句中的!x与下面条件表达式等价的是:。 A) x!=0 B) x==1 C) x!=1 D) x==0 4.已知 struct point { int x; int y; }; struct rect { struct point pt1; struct point pt2; }; struct rect rt; struct rect *rp = &rt; 则下面哪一种引用是不正确的________。 A) B) (*rp). C) rp-> D)rt-> 5.若二维数组a有m行n列,则下面能够正确引用元素a[i][j]的为:。 A) *(a+j*n+i) B) *(a+i*n+j) C) *(*(a+i)+j) D) *(*a+i)+j CDDDC 二、分析程序并写出运行结果。(25分,每题5分) 1.#include <> main() {int n; static char *monthName[]= {"Illegal month", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; for (n=1; n<=12; n++) { printf("%s\n", monthName[n]); } } 运行结果是: January

相关主题
文本预览
相关文档 最新文档