PRF192 - Unit 1-5

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

A D

(1) One byte consists of 4 nibbles. (2) One nibble consists of 2 consecutive bits Choose at least one answer. a. (1): false b. (1) true. c. (2): true. d. (2): false

B

....... helps identifying the device which will communiate with CPU. Choose at least one answer. a. Address bus. b. All c. Control bus. d. Data bus.

B

/* Suppose that all needed libraries are included */ int main() { int n, m; int result = scanf("%d%d",&n, &m); printf("%d", result); getch(); return 1; } What is the ouput of the above program if input is 12asd45 ? Choose one answer. a. a non-predictable value. b. 1 c. 3 d. 2 e. An error is thrown when it executes.

C

/* Suppose that all needed libraries are included */ int main() { int n, m; scanf("%d,%d",&n, &m); printf("%d, %d", n, m); getch(); return 1; } When the program executes, user enters 9 100 . What is output? Choose one answer. a. Two non-predictable values. b. No output is printed out. c. 9 and a non-predictable value. d. An error when it executes.

D

/* Suppose that all needed libraries are included */ int main() { int n; char c; scanf("%d",&n); c=getchar(); printf("%d, %d", n,c); getch(); return 1; } What is the output of the above program if user enters the keys 12 and ENTER? Choose one answer. a. Non-predictable values. b. 12 c. No output is printed out. d. 12, 10 e. 12, 13

E

1. Intel use this little-endian ordering 2. Motorola use middle-endian ordering 3. Motorola use big-endian ordering 4. Intel use this big-endian ordering Choose one answer. a. 2, 3 true b. All of them are true c. 1, 4 true d. 2, 4 true e. 1, 3 true f. 1, 2 true g. All of them are false

A B C

Comments of a program ...... Choose at least one answer. a. are used for documenting a program. b. are omitted by the compiler. c. enhance the readability of a program. d. are translated into instructions after the program is compiled.

D

Data is stored in computer memory in ......... Choose one answer. a. decimal format. b. hexadecimal format. c. octal format. d. binary format.

B

Flags is a technique that supports using goto, continue statements Choose one answer. a. True b. False

B C

In C language, (1) The == operator is used for setting a value to a variable. (2) The = operator is used for checking whether two numbers are equal or not. Choose at least one answer. a. (2): true. b. (2): false c. (1): false d. (1) true.

B D E

In C language, the selection constructs use ....... Choose at least one answer. a. while b. switch c. for d. ?: e. if else f. if else then

A B D

In C, incorrect order(s) of a function implementation: Choose at least one answer. a. Return type, body, function name, parameters b. Return type, body, parameters, function name c. Return type, function name, parameters, body d. Return type, parameters, body, function name

B D

In C, select correct statements. Choose at least one answer. a. The expression x=y; will copy value of the variable x to the variable y. b. The expression x=y; will copy value of the variable y to the variable x. c. A constant character must be enclosed by a pair of double or single quotes. d. A constant string must be enclosed by a pair of double quotes.

A D E

In C, which of these statements are not true? Choose at least one answer. a. #include "filename" using with filename locate in system directory. b. We can collect function prototypes into a file and refer to the file in our program c. We use the #include directive to instruct the compiler to insert a copy of the header file into our source code. d. #include <filename> using with filename locate in user directory e. # is a symbol of postprocessor indicators

C

In C, with reference to property of reusing a function, the function that will check whether an integer is a prime or not, should be declared as ........ Choose one answer. a. a void function. b. a function that returns a real number. c. a function that will return an integer. d. None of the others e. a function that returns a string a characters.

B

Marks: 1 1. The rule in C is that an else statement always belongs to the innermost if available 2. The rule in C is that an else statement always belongs to the outermost if available Choose one answer. a. Only 2nd statement is true b. Only 1st statement is true c. Both 1 and 2 statements are false d. Both 1 and 2 statements are true

B C D

Program .... Choose at least one answer. a. is a collection of functions. b. is a simulation of solution. c. is the result of a programming process. d. is a set of instructions that computer hardware will execute. e. is written by C language only.

B C

Program should be written ... Choose at least one answer. a. with a complicated appearance. b. as a well program. c. with a consistent style and clear throughout. d. with significant effort and private style.

B D E

Select correct conversion specifiers for an int variable in C lanaguge. Choose at least one answer. a. %f b. %o c. %e d. %d e. %u

A B D

Select correct properties of C language. Choose at least one answer. a. C source code must be translated into executable code by a compiler. b. C language is a functional language. c. C language is case-insensitive language. d. C is case sensitive language. e. C language is a low-level language.

C D

Select correct statement(s). Choose at least one answer. a. Actual parameter is a parameter in function implementation. b. Formal parameter is a parameter that is transfered to a function when it is called. c. Actual parameter is a parameter that is transfered to a function when it is called. d. Formal parameter is a parameter in function implementation.

C D E

Select correct statement(s). Choose at least one answer. a. Walkthrough is a process in which any change in codes is recorded. b. Walkthrough process is used for evaluating the performance of a program. c. A table that contains all program variables is used in walkthrough process. d. Walkthrough is a manual process for recording all changes of program variables when the program executes instruction-by-instruction. e. A listing of the output, if any, produced by the program is carried out when we do a walkthrough..

B C

Select correct statements. Choose at least one answer. a. A compiler will translate each statement of source code into machine code then CPU executes this statement. b. An interpreter will iterate to translate each statement of source code into machine code then CPU execute these binary code of this statement. c. Compiler of the language A can translate A-source code into language B-source code then the B-language compiler will translate B-source code into machine code. d. An interpreter will translate all source codes into machine codes then CPU executes them as a whole.

C D E

Select correct statements. With respect to ASCII, .......... Choose at least one answer. a. Binary ASCII code of the character a is 0100 0001 b. Binary ASCII code of the digit 1 is 0000 0001 c. Binary ASCII of the character A is 0100 0001 d. The code of a uppercase character is less than the code of a lowercase character. e. The code of a digit is less than the code of an alphabet.

A C D

Select incorrect statements. Choose at least one answer. a. The specifier %hex is used for printing out an integer in hexadecimal format. b. The specifier %e is used for printing out a real number in scientific format. c. The specifier %u is used for printing out a unsigned integer. d. The specifier %b is used to print out an integer in binary format.

A D

Select the statements that belong to low cohesion Choose at least one answer. a. "logical" - related tasks of which only one is performed - the module identifier suggests a choice b. "functional" - performs a single specific task - the module identifier suggests a precise verb phrase c. "communicational" - the tasks share the same data - all tasks are carried out each time d. "coincidental" - unrelated tasks

D

Study the following function: int t (int x, int y, int z) { return x+y+z>20 ? 10 : 20; } If this function is called as following with input data are 5 10 15. What is the output? int a,b,c; printf("Enter 3 integers:"); scanf("%d%d%d", &a, &b, &c); printf("%d", t(b,c,a)); Choose one answer. a. None of the others. b. 20 c. -10 d. 10

C

Study the function implementation and a case of using this function. int t (int x, int y) { return x-y; } ... char c1= 'A', c2= 'D'; printf("%d", t(c2, c1)); Suppose that the above codes execute. What is the output? Choose one answer. a. An error is thrown when they are executed. b. No output is printed out. c. 3 d. -3

D

Suppose that the following codes are executed. What is the output? long S=10; long i=1; while (i<=10) { if (i%2==0) S+=i; i++; } printf("%ld", S); Choose one answer. a. 32 b. 38 c. 46 d. 40 e. 36

C

Suppose that the following codes execute and input data are 9 and 12. int m,n; printf("Enter two integers:"); scanf("%d%d",&m, &n); if (m>10 && n<20) printf("%d", m+n); else printf("%d", m-n); What is the output. Choose one answer. a. None of the others. b. 21 c. -3 d. 3

A

Suppose that the following codes execute. What is the output. int n=3, m=7; int* p1= &n, *p2=&m; *p1 -= m+n- 3*(*p2); *p2 += m-n; printf ("%d", m+n); Choose one answer. a. 14 b. 16 c. 12 d. 20 e. 18

E

Suppose that the following codes execute. What is the output? long S=10; long i; for (i=1; i<10; i++) if (i%3==0) S+=i; printf("%ld", S); Choose one answer. a. 19 b. 31 c. 16 d. 22 e. None of the others.

B

The getchar function can do Choose one answer. a. clearing the buffer automatically after retrieving b. None of the others c. treats the whitespace between the input values as a separator d. retrieves data values from every keystroke directly

A C D

To improve readability, programmers are recommended ....... Choose at least one answer. a. using whitespace to identify the logical structure of the code. b. using goto statements as needed. c. removing continue statements. d. using break statements as needed. e. using comments.

D

Validation do not include Choose one answer. a. out-of-range input b. invalid characters c. trailing characters d. None of the others e. incorrect number of input fields

B C E

What are the right matching? Character Sequence a. Newline \t b. vertical tab \v c. backslash \ d. alarm \r e. backspace \b f. question mark \? Choose at least one answer. a. a b. f c. e d. c e. b f. d

B

What is the output if the following code executes. int n=3, m=7; int* p1= &n, *p2=&m; *p1 -= m+n- 3*(*p2); *p2 += *p1%2 ? 2 : 5; printf ("%d", m-n); Choose one answer. a. -5 b. None of the others. c. -4 d. 6 e. 4

E

What is the output of the following program? /* Suppose that all needed libraries are included */ int main() { double x= 3.5, y= 6.8 , z= 1.5; int n= floor( x )+ ceil( y )+ z; printf("%d", n); getch(); return 1; } Choose one answer. a. 12 b. 10 c. 11.5 d. The program causes an error when it is compiled. e. 11

C

What library includes function to generate random numbers? Choose one answer. a. conio.h b. stdio.h c. stdlib.h d. math.h

A D E

Which of the following is an invalid identifier? Choose at least one answer. a. employee salary b. False c. _123 d. +ab e. 45n f. True

A C D

Which of these definitions are true? Choose at least one answer. a. The CPU performs the operation on the values stored as operands or on the values stored in the operand addresses. b. The addresses are specific values of a program. c. The addresses are either register names or primary memory addresses. d. Each program instruction consists of an operation and operands. e. Each program instruction consists of an expression only.

A D

Which of these statements about constants are not true? Choose at least one answer. a. The compiler allocates memory for constants. b. The compiler does not allocate memory for constants. c. The compiler embeds constants directly into the program instructions. d. The compiler compiles constants.

D

Which of these statements about format string are not true? Choose one answer. a. size identifies the size of data type of the value passed. b. % flags width . precision size conversion_character c. - describes left justification of the converted value in its field d. None of the others e. 0 pads the field width with leading zeros

D

Which of these statements about fundamental unit in CPU is true? Choose one answer. a. The natural unit of the CPU is a int b. The natural unit of the CPU is a numeric c. The natural unit of the CPU is a bit d. The natural unit of the CPU is a word e. The natural unit of the CPU is a byte

C D

Which of these statements about primary memory are not true? Choose at least one answer. a. Primary memory holds the information accessed by the CPU. b. RAM is a volatile memory. c. There is only one operation on primary memory and it is reading. d. ROM is a volatile memory. e. Primary memory is addressable.

E

Which of these statements about the function is true? Choose one answer. a. All of the others b. The body is the code block that contains the module instructions and generates the return value c. A function definition consists of a header and a body d. A function that does not return a value is called a subroutine or procedure in other languages e. A function may receive data and may return a value

C D E

Which of these statements about the scanf function are true? Choose at least one answer. a. The return code from scanf reflects success of %* conversions b. scanf retrieves data values from every keystroke directly c. interpreted and processed the entire format string d. scanf treats the whitespace between the input values as a separator e. If the buffer is empty, the function scanf will wait until the user adds more data values

A E

Which type qualifiers are defined in C? Choose at least one answer. a. short b. complex c. double d. array e. long


Ensembles d'études connexes

Using the Internet as a Source of Information

View Set

Industrial Microbiology and Biotechnology Final

View Set

Fair Credit Reporting Act (FCRA)

View Set

WORLD HISTORY; Age of Exploration Test

View Set

HESI CASE STUDY: LOSS, GRIEF, DEATH

View Set

Test #2 Data Structures & Algorithms

View Set