大学MOOC Fundamentals of C Programming(Northwestern Polytechnical University)1457957182 最新慕课完整章节测试答案
Chapter 1 Introducing C-2
文章目录
- Chapter 1 Introducing C-2
- Chapter 10 Files
- Chapter 2 Data Types and Expression -2
- Chapter 2 Data Types and Expression -3
- Chapter 3 program control structure -2
- Chapter 3 program control structure -4
- Chapter 3 program control structure -5
- Chapter 4 The Preprocessor
- Chapter 5 Array-2
- Chapter 6 Functions
- Chapter 7 Pointers
- Chapter 8 Strings
- Chapter 9 Structures
Quiz 1 Introducing C
1、单选题:
When compile a C program, the comments will .
选项:
A: be compiled and appear in the object code.
B: be compiled, but not appear in the object code.
C: not be compiled and not appear in the object code.
D: not be compiled, but appear in the object code
答案: 【 not be compiled and not appear in the object code.】
2、单选题:
A file written by C language .
选项:
A: can be executed immediately.
B: is a source program.
C: can be executed after compilation.
D: can be executed after compilation and interpretation.
答案: 【 can be executed after compilation.】
3、判断题:
Many programming languages borrow heavily form C language, including C++, C# .
选项:
A: 正确
B: 错误
答案: 【 正确】
4、判断题:
One of C’s advantages is efficiency. Because C was intended for applications where assembly language had traditionally been used, it was crucial that C programs could run quickly and in limited amounts of memory.
选项:
A: 正确
B: 错误
答案: 【 正确】
5、判断题:
C’s weaknesses arise from the same source as many of its strengths: C’s closeness to the machine.
选项:
A: 正确
B: 错误
答案: 【 正确】
Chapter 10 Files
Quiz 13 Files
1、单选题:
Which one of the following is correct about data file and C language?
选项:
A: Files consist of ASCII character sequence and C language can only read and write text files.
B: Files consist of binary data sequence and C language can only read and write binary files.
C: Files consist of records sequence and can be categorized into binary files and text files by the storage form of the data.
D: Files consist of data streams and can be categorized into binary files and text files by the storage form of the data.
答案: 【 Files consist of data streams and can be categorized into binary files and text files by the storage form of the data.】
2、单选题:
The system standard input file is .
选项:
A: monitor
B: floppy disk
C: hard disk
D: keyboard
答案: 【 keyboard】
3、单选题:
The system standard output file is .
选项:
A: hard disk
B: keyboard
C: floppy disk
D: monitor
答案: 【 monitor】
4、单选题:
Which one of the following is a correct file name argument for the function fopen?
选项:
A: c:usertext.txt
B: c:\user\text.txt
C: "c:usertext.txt"
D: "c:\user\text.txt"
答案: 【 "c:\user\text.txt"】
5、单选题:
Given char fname[]="infile.dat"; , which one of the following is a correct way to open the text file infile.dat for reading?
选项:
A: fopen(infile,"r")
B: fopen("infile","r")
C: fopen("fname","r")
D: fopen(fname,"r")
答案: 【 fopen(fname,"r")】
6、单选题:
Which one of the following is a correct way to create a file for both reading and writing using the function fopen ?
选项:
A: "ab+"
B: "rb+"
C: "ab"
D: "wb+"
答案: 【 "wb+"】
7、单选题:
If errors occur while executing the function fopen, what is its return value?
选项:
A: the address
B: 1
C: EOF
D: NULL
答案: 【 NULL】
8、单选题:
If open an existing file using the argument "a+", which one of the following is correct?
选项:
A: When it is open, the origin file content remains, the accessing pointer moves to the beginning of the file and rewriting/reading operations are available.
B: When it is open, the origin file content is deleted, only reading operation is available.
C: None of the above is correct.
D: When it is open, the origin file content remains, the accessing pointer moves to the end of the file and appending/reading operations are available.
答案: 【 When it is open, the origin file content remains, the accessing pointer moves to the end of the file and appending/reading operations are available. 】
9、单选题:
In the file open modes, the string "rb" indicates .
选项:
A: opening a text file only for data writing.
B: opening an existing text file only for data reading.
C: opening a binary file only for data writing.
D: opening an existing binary file only for data reading.
答案: 【 opening an existing binary file only for data reading.】
10、单选题:
When opening the text file "a:\aa.dat" in the mode "w", if the file already exists, .
选项:
A: the new data will be appended to the end of the file.
B: the error message will be displayed.
C: the new data will be insert into the beginning of the file.
D: the file will be clear and the new data is written from the beginning.
答案: 【 the file will be clear and the new data is written from the beginning.】
11、单选题:
In C program, which one of the following can write an integer data into a file in binary form?
选项:
A: fprint
B: fputs
C: fputc
D: fwrite
答案: 【 fwrite】
12、单选题:
Which one is the prototype of the function fputc that write a character to the disk files?
选项:
A: FILE* fputc(char)
B: int fputc(FILE *)
C: int fputc(FILE *,char)
D: int fputc(char,FILE *)
答案: 【 int fputc(char,FILE *)】
13、单选题:
Which one of the following operations can be done using the function fseek?
选项:
A: sequential file access
B: random file access
C: all of the above
D: changing the file position associated with the file pointer.
答案: 【 changing the file position associated with the file pointer.】
14、单选题:
The function calling fseek(fp,-20L,SEEK_END) complete the operation .
选项:
A: moving the file pointer to the location 20 bytes to the file header.
B: moving the file pointer 20 bytes forward from the current location.
C: moving the file pointer 20 bytes backward from the current location.
D: moving the file pointer 20 bytes backward from the end of the file.
答案: 【 moving the file pointer 20 bytes backward from the end of the file.】
15、单选题:
Which one of the following codes is nearly equal to fseek(fp,0L,SEEK_SET)?
选项:
A: feof(fp)
B: ftell(fp)
C: fgetc(fp)
D: rewind(fp)
答案: 【 rewind(fp)】
16、单选题:
The function rewind can .
选项:
A: move the file pointer to the specific location of the file.
B: move the file pointer to the end of the file.
C: move the file pointer to the location of the next character.
D: move the file pointer to the beginning of the file.
答案: 【 move the file pointer to the beginning of the file.】
17、单选题:
The function ftell(fp) can .
选项:
A: move the pointer of the stream file.
B: initialize the pointer of the stream file.
C: all the above.
D: get the current location of the stream file.
答案: 【 get the current location of the stream file.】
Chapter 2 Data Types and Expression -2
Quiz 2 DataType, Variable and Constant
1、单选题:
Which of the following is a legal C identifier?
选项:
A: 1stuNPU
B: Stu@NPU
C: stu-NPU
D: _stu_NPU
答案: 【 _stu_NPU】
2、单选题:
Which of the following is not keyword in C language?
选项:
A: do
B: int
C: void
D: main
答案: 【 main】
3、单选题:
Which of the following is NOT a constant in C language?
选项:
A: 012
B: "a"
C: 'n'
D: 'AB'
答案: 【 'AB'】
4、单选题:
Which of the following is NOT a float constant in C language?
选项:
A: 2.38
B: .23
C: 1.2e-2
D: e-2
答案: 【 e-2】
5、判断题:
The three identifiers, weight, Weight and WEIGHT, are NOT equal in C language.
选项:
A: 正确
B: 错误
答案: 【 正确】
Chapter 2 Data Types and Expression -3
Quzi 3 Operators and Expression
1、单选题:
In C language, which of the following operator requires its operands must be of type int?
选项:
A: /
B: *
C: =
D: %
答案: 【 %】
2、单选题:
Of which operation the precedence is higher than others’?
选项:
A: +
B: %
C: *
D: ()
答案: 【 ()】
3、单选题:
The value of the expression 3.6-5/2+1.2+5%2 is ____.
选项:
A: 4.3
B: 4.8
C: 3.3
D: 3.8
答案: 【 3.8】
4、单选题:
Suppose all variables in the following expressions have been declared and initialized, which of the following is NOT a legal expression in C language?
选项:
A: a = (2, b= c + 2)
B: (int)18.5%3
C: a = b += c + b
D: a := b + 1
答案: 【 a := b + 1】
5、单选题:
If an expression is the sum of four data of different types, including int, long, double and char, the expression’s type is ____.
选项:
A: int
B: long
C: char
D: double
答案: 【 double】
6、判断题:
The expressions ++i and i++ are exactly NOT the same as (i += 1).
选项:
A: 正确
B: 错误
答案: 【 正确】
Chapter 3 program control structure -2
Quiz 4 Formatted Input & Output
1、单选题:
If c is a variable of type char, which one of the following statements is illegal?
选项:
A: i += c; /*i has type int*/
B: c = 2*c – 1;
C: putchar(c);
D: printf(c);
答案: 【 printf(c);】
2、单选题:
Suppose that we call scanf as follows:scanf(“%d%f%d”, &i, &x, &j);If the user enters:10.8 9 3↙What will be the values of i, x, and j after the call? (Assume that i and j are int variables and x is a float variable. ↙ is used to represent Enter key)
选项:
A: 10 9 3
B: 11 9 3
C: 10.8 9 3
D: 10 0.8 9
答案: 【 10 0.8 9】
3、单选题:
Suppose that we call scanf as follows:scanf(“%f%d%f”, &x, &i, &y);If the user enters:12.3 45.6 789What will be the values of x, i, and y after the call? (Assume that x and y are float variables and i is an int variable. ↙ is used to represent Enter key)
选项:
A: 12.3 45 789
B: 12.3 45.6 789
C: 12 45 789
D: 12.3 45 0.6
答案: 【 12.3 45 0.6】
4、单选题:
Which one of the following is correct?
选项:
A: The output item must be given when calling function printf.
B: When calling function getchar to read in a character, we can input its corresponding ASCII code.
C: In C language, integers can be output in various forms, e.g. decimal, binary, octal and hexadecimal.
D: The header file stdio.h must be included before calling function putchar.
答案: 【 The header file stdio.h must be included before calling function putchar.】
5、单选题:
Assuming the following statements:char c1='1',c2='2';c1=getchar();c2=getchar();putchar(c1);putchar(c2);If input a└┘↙ when run the code, ↙ is used to represent Enter key, └┘ is used to represent space, which one of the following statements is correct?
选项:
A: The program will wait for the second character input by user.
B: Variable c1 is assigned the character a, and c2 remains the character 2.
C: Variable c1 is assigned the character a, and c2 remains uncertain value.
D: Variable c1 is assigned the character a, and c2 is assigned the space character.
答案: 【 Variable c1 is assigned the character a, and c2 is assigned the space character.】
6、单选题:
Given the following declarations and scanf function call statements, to make the value of a1, a2, c1, c2 to be 10, 20, A and B respectively. Which one of the following inputs is correct? ↙ is used to represent Enter key and └┘ is used to represent space. ( D )int a1,a2;char c1,c2;scanf("%d%d",&a1,&a2);scanf("%c%c",&c1,&c2);
选项:
A: 1020AB↙
B: 10└┘20↙AB↙
C: 10└┘20└┘AB↙
D: 10└┘20AB↙
答案: 【 10└┘20AB↙】
7、单选题:
Assuming the statement scanf("a=%d,b=%d,c=%d",&a,&b,&c); To make the values of a, b, and c to be 1, 3, 2 respectively, which of the following input is correct? ↙ is used to represent Enter key and └┘ is used to represent space.
选项:
A: 132↙
B: 1,3,2↙
C: a=1└┘b=3└┘c=2↙
D: a=1,b=3,c=2↙
答案: 【 a=1,b=3,c=2↙】
8、单选题:
If the variable x is of type double, which one of the following statements is right?
选项:
A: scanf("%f",x);
B: scanf("%f",&x);
C: scanf("%5.1f",&x);
D: scanf("%lf",&x);
答案: 【 scanf("%lf",&x);】
9、单选题:
What is the output of the following code? └┘ is used to represent space. float x=-1023.012;printf("%8.3f,",x);printf(" % 10.3f",x);
选项:
A: 1023.012,-1023.012
B: –1023.012,-1023.012
C: 1023.012,└┘-1023.012
D: –1023.012,└┘-1023.012
答案: 【 –1023.012,└┘-1023.012】
10、单选题:
What is the output of the following code?int x=13,y=5;printf("%d",x%=(y/=2));
选项:
A: 3
B: 2
C: 0
D: 1
答案: 【 1】
11、单选题:
If we declared int a=1234;, what is the result when executing the statement printf("%2d",a);?
选项:
A: 12
B: 34
C: Error
D: 1234
答案: 【 1234】
12、单选题:
What is the output of the following code? int a;char c=10;float f=100.0;double x;a=f/=c*=(x=6.5);printf("%d %d %3.1f %3.1f",a,c,f,x);
选项:
A: 1 65 1 6.5
B: 1 65 1.0 6.5
C: 2 65 1.5 6.5
D: 1 65 1.5 6.5
答案: 【 1 65 1.5 6.5】
13、单选题:
Execute the following statements, if input 12345678↙,what is the output?int a , b ;scanf("%2d%*2d%3d",&a,&b);printf("%d",a+b);
选项:
A: 46
B: 5690
C: Error
D: 579
答案: 【 579】
14、判断题:
C compilers are required to check that the number of conversion specifications in a format string matches the number of output items.
选项:
A: 正确
B: 错误
答案: 【 错误】
15、判断题:
If the format string is “%dn”, scanf will skip white space, read an integer, and then skip to the next non-white-space character. So a format string like this can cause an interactive program to “hang” until the user enters a nonblank character.
选项:
A: 正确
B: 错误
答案: 【 正确】
Chapter 3 program control structure -4
Quiz 5 Selection Structure
1、单选题:
After the execution of the following statements:int a=1, b=2, c=3, d=4, m=2, n=2, cond;
cond = (m=a>b) && (n=c>d);, which one of the following value is equal to the value of n ?
选项:
A: 1
B: 2
C: 3
D: 4
答案: 【 2】
2、单选题:
Suppose i is a variable of type int, and its value is 10, which of the following is the value of expression 30-i<=i<=9 ?
选项:
A: 0
B: 1
C: 9
D: 20
答案: 【 1】
3、单选题:
After the execution of the following statements:int a=0,b=0,m=0,n=0;
(m=a==b)||(n=b==a);,the values of m and n are and respectively?
选项:
A: 0 0
B: 1 0
C: 0 1
D: 1 1
答案: 【 1 0】
4、单选题:
Which of the following is equal to the expression !x ?
选项:
A: x==1
B: x==0
C: x!=1
D: x!=0
答案: 【 x==0】
5、单选题:
Suppose int x=3,y=4,z=5;, which of the following is the value of the expression !(x+y)+z-1 && y+z/2 ?
选项:
A: 6
B: 1
C: 2
D: 0
答案: 【 1】
6、单选题:
Which of the following is not a legal expression in C language?
选项:
A: 0<=x<100
B: x+1=x+1
C: i=j==0
D: (char)(x<100)
答案: 【 x+1=x+1】
7、单选题:
The expression in if(expression) can be .
选项:
A: logical expression
B: any of the above
C: relational expression
D: arithmetic expression
答案: 【
