midterm C

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Evaluate the expression 3*4 %6 + 4*5 A.20 B.26 C.12 D. 32

A. 20

Which of the following would not be considered hardware? A. An operating system B. A CPU C. A keyboard D. a disk

A. An operating system

The compile stage is when _______ A. the object code is linked with code for functions in other files B. The C program is translated into machine language code C. the program is executed one instruction at a time D. The program is placed in memory

B

The pair of braces that delineate the body of main and the portion of the program between these A. function B.Block C.Statement D. Header

B

Which of the following statements is true ? A. Interpreted programs run faster than compiled programs B. Compilers translate high-level language program into machine-language program C. Interpreter programs typically use machine language as input D. None of the above

B

In C the condition 4>y>1 A. evaluates correctly B. does not evaluate correctly and should be replaced by ( 4>y && y>1) C. does not evaluate correctly and should be replaced by ( 4>y & y>1) D. does not evaluate correctly and should be replaced by ( 4>y || y>1)

B. does not evaluate correctly and should be replaced by ( 4>y && y>1)

Which of the following is an incorrect expression to increment c by 1 in the increment expression of a for " header"? A. c += 1 B. ++c C.c++ D. c+1=c

D c+1=c

Which statement is false? A. Every block is a compound statement B. Every compound statement is a block C. Blocks can be nested D. Compound statement can be nested

B

Which is not a scope for an identifier A. function scope B.record scope C. block scope D. function prototype scope

B . record scope

Programs that directly execute high-level language programs without compiling are called____ A. assemblers B. interpreters C. compliers D. translators

B. interpreters

Experience has shown that the best way to construct a program is from small pieces. This is called ____ A. bottom up B. the whole is greater than the sum of the parts C. divide and conquer D. recursion

C

In the expression n = a +rand() %b; A. b is the shifting value B. a is the scaling value C. b is equal to the width of the desired range of integers D. none are correct

C. b is equal to the width of the desired range of integers

An identifier's ___ is where the identifier can be referenced in a program A. locality B. Vicinity C. Neighborhood D. Scope

D. scope

Which of the following must every C program have? A. main B. #include C./* D.<stdio.h>

A

Which statement automatically handles all the details of counter-controlled iteration A. for B. while C. do... while D. continue

A. for

Labels are the only identifiers with A. function scope B. file scope C.block scope D. function prototype scope

A. function scope

The __ selection statement perform an action if a condition is true and skips that action if the condition is false A.if B. when C. if... else D. switch

A. if

The conditional operator (?:) _____________ A. is the only ternary operator in C B . Is a unary operator C. associates from left to right D. Accepts two operands

A. is the only ternary operator in C

Which of the following is going to be the key programming method A. object-oriented programming B. structured programming C. " legacy C code" D. " live-code approach"

A. object-oriented programming

Which statement is true ? A. Each of C's control statements is characterized as being single-entry, single-exit. B. Each of C's control statements is characterized as being single-entry, multiple-exit C.Each of C's control statements is characterized as being multiple entries, single exit D.Each of C's control statements is characterized as being multiple entry, multiple exits

A. single entry, single exit

An uninitialized variable contains: A. the value last stored in the memory location reserved for that variable B. no value C. a value of zero D. a randomly assigned value

A. the value last stored in the memory location reserved for that variable

Variable names actually correspond to ___ A. location in the computer's memory B. Operators C. Integers D. Data types

A.location in the computer's memory

Which statement is false ? A. the ANSI C standard does not specify the order in which the operands of most operators are to be evaluated B. The ANSI C standard specifies the order of evaluation of operators &&,||, comma and ?: C. a program that evaluates Fibonacci numbers recursively achieves high performance because of exponential D. programs that depend on the order of evaluation of the operands of operators other than &&,||,comma and ?:

B

Which operator will find the remainder when 15 is divided by 6 ? A. 15/6 B. 15%6 C. 15^6 D. 15*6

B.

If a = 7.0, b = 7.0 and c = 6.0, then what is printed by printf( "%.2f", sqrt( a + b * c ) ); a) 49 b) 7.00 c) 7 d) 49.00

B. 7.00

which standard library header file contains prototypes for conversions of number to text and text to numbers, memory allocation, random numbers a. <stdarg.h> b.< stdlib.h> c.< stdutl.h> d. <stddef.h>

B. <stdlib.h>

The _____- sign is also known as the ______ operator A. + , assignment B. =, assignment C. *, stream manipulator D. &, stream insertion

B. =, assignment

Indentation in the if selection statement is _______ A. Always mandatory B. Always optional C. Only mandatory if there is more than one statement following the if statement D. Only optional if there is more than one statement following the if statement

B. Always optional

The _______,________ and _______ are the only three forms of control necessary A. switch, if, else B. Sequence, selection , iteration C. Break, continue, if...else D. for, while, do.... while

B. Sequence, selection , iteration

Which statement regarding the switch statement is false ? A. It's appropriate for algorithms that contain a series of decisions in which a variable or expression is tested separately for each of the constant B. The default cause is required C. The default case must be at the bottom of the switch after all the non-default cases D. Many cases may all invoke the same code

B. The default cause is required

Which statement is false? A. A compound statement can be placed anywhere in a program that a single statement can be placed B. The if selection statement can have only one statement in its body C. A set of statements contained within a pair of braces (( and )) is called a compound statement D. An if selection statement can have a compound statement in its body

B. The if selection statement can have only one statement in its body

Which of the following is true about undefined behavior, which can leave a system open to attack? A. it's not possible to have undefined behaviour when adding two integers B. adding two integers can result in arithmetic overflow, which can cause undefined behavior C. you should not worry about undefined behavior in your programs D. none of the above

B. adding two integers can result in arithmetic overflow, which can cause undefined behavior

Placing a semicolon after the parenthesized in an if statement leads to a_______ error in single selection if statements and a ___ error in A. logic, logic B. logic, syntax C. syntax, logic D. syntax, syntax

B. logic, syntax

_______ iteration is sometimes called indefinite iteration A. counter-controlled B. sentinel -controlled C. variable-controlled D. none of the above

B. sentinel-controlled

The OR (||) operator A. has higher precedence than the AND (&&) operator B. stops evaluation upon finding one condition to be true C. Associates from right to left D. Is a ternary operator

B. stops evaluation upon finding one condition to be true

Which is not an attribute of a variable? A. storage class B. storage duration C. scope D. external class

B. storage duration

Which statement is false? A. whitespace characters such as tabs, newlines and spaces are generally ignored by the C complier B. the statements in an if statement must be indented C. Placing a blank line before and after every control structure can improve program readability D. There can be ( but should not be) more than one statement per line

B. the statements in an if statement must be indented

An identifier's storage class: a. Determines whether an identifier is known only in the current source file or in any source file with proper declarations. b. Determines the period during which that identifier exists in memory. c. Determines where the identifier can be referenced in a program. d. All of the above.

B.Determines the period during which that identifier exists in memory.

Recursion is memory-intensive because: A. it must occur numerous times before it terminates B.Previous function calls are still open when the function calls itself and the activation records of these previous calls still occupy space on the call stack. C. many copies of the function code are created D. it requires large data values

B.Previous function calls are still open when the function calls itself and the activation records of these previous calls still occupy space on the call stack.

Programs or data not actively being used by the other units are placed on the _____ A. output unit. B.memory unit C. secondary storage unit D.central processing unit

C

The following line is a most properly an example of a ____ puts " Welcome to C " A. Function B. Block C. Statement D. Header

C

Which of the following statements is true ? A. Function scanf does not return a value B. You should never check the return value of function scanf C.You should check the return value of function scanf to ensure that the value it returns matches the D. None of the above

C

Which statement is used to skip the remainder of the body of an iteration statement and proceed with the next iteration of the loop ? A. skip B. proceed C. continue D. jump

C . continue

Using an incorrect relational operator or using an incorrect final value of a loop counter in the condition of a while o rfor statement is a frequent cause of __________errors. A. syntax B. compilation C. off by one D. divide by zero

C . off by one

Which of the following is an iteration statement ? A. If B. If .... else C. Do ..... while D. Switch

C Do ... while

If a do ....while statement is used A. an infinite loop will not take place B. the counter must be preincremented if it's also the condition C. the body of the loop will execute at least once D. an off-byy-one error will not occur

C the body of the loop will execute at least once

A correct decision symbol has _____ flowlines emerging from it A. 4 B. 3 C. 2 D. 1

C. 2

Any C program we'll ever need to build can be constructed from only ____ different control A. 7,3 B. 6,2 C. 7,2 D. 6,3

C. 7,2

What is produced by a for statement with a correct body and with the following header ? For (i=20,i>=2,i+=2) A. syntax error b. a divide by zero error C.an infinite loop D. the even value of i from 20 to 2

C. An infinite loop

Which statement is true ? A. When an argument is passed call by reference, a copy of the argument's value is made and passed B. with call by reference, change to the passed value do not affect the original variable's value of the C. Call by value should be used whenever the called function does not need to modify the value of the D. Call by value should only be used with trusted called function

C. Call by value should be used whenever

Each standard library has a corresponding: A. Function B. Variable type C. Header file D. CD-rom

C. Header file

Which statement is false? A. Pseudocode is an artificial and informal language that helps you develop algorithms B. Pseudocode is similar to everyday English C. Pseudocode is an actual programming language D. Pseudocode programs are not actually executed on computers

C. Pseudocode is an actual programming language

In the context of counter-controlled iteration, which of the following is not accomplished by the control-value A. Names the control variable B. Defines the control variable to be an integer C.Specifies the sentinel value D. Sets the initial value of the control variable to 10

C. Specifies the sentinel value

Which statement is false? A. It is not correct to split an identifier with a space, a tab or a newline B. Statements and comments may be split over several lines C. The equal sign (=) is not an operator D. a good programming practice is to break a line after a comma in a lengthy comma-separated list

C. The equal sign (=) is not an operator

Which statement is true ? A. the do .... while iteration statement is an alternate notation for the while iteration statement B. The do .... while iteration statement tests the loop-continuation condition before the loop C. The loop body of a correct do ... while iteration statement is always executed at least once D. The braces delineating the body of a do ... while statement are always required

C. The loop body of a correct do ... while iteration statement is always executed at least once

Which statement is false? A. Comma operators evaluate lists of expressions from right to left B. The value of a comma-separated list of expressions is the value of the rightmost expression C.The type of a comma-separated list of expressions is the type of the rightmost expression D.The comma operator is often used to specify multiple initializations in one particular type of

C. The type of a comma-separated list of expressions is the type of the rightmost expression

A recursive function is a function that _________ A. returns a double B. Takes 3 arguments C. Calls itself D. is inside of another function

C. call itself

The forcing of arguments to the appropriate types is commonly called _______ A. conversion B.casting C.coercion D.transmogrification

C. coercion

Small circle symbols in a flowchart are often called _______ symbols A. little circle B. collision C. connector D. collator

C. connector

Which of the following is not a synonym for " sentinel value" A. signal value B. dummy value C. counter value D. flag value

C. counter value

Recursion is to the base case as iteration is to ____? A. the counter B. An iteration statement C. failure of the loop continuation test D. A selection statement

C. failure of the loop continuation test

The ____ is called a double selection statements A. if B. When C. if ... else D. switch

C. if...else

Which of the following is not an indication that a function may be too complex? A. it has a large size B. it has a large parameter list C. its name is a clear reflection of its function D. it performs multiple tasks

C. its name is a clear reflection of its function

Specifying the order in which statements are to be executed in a computer program is called A. An algorithm B. transfer of control C. program control D. pseudocode

C. program control

Which software product release category is " generally feature complete and supposedly bug free and A. Alpha B. Beta C. Release candidate D. Continuous beta

C. release candidate

Various C statements enable you to specify that the next statement to be executed may be other than the next one in sequence. This is called A. change of order B. instruction skipping C. Transfer of control D.rerouting

C. transfer of control

Which statement is true ? A. Use float variables to perform monetary calculation in C. B. Use double variables to perform monetary calculation in C C. Monetary calculations can be performed in C D. Printing with %.2f guarantees correct monetary calculations in C

C.Monetary calculations can be performed in C

A valid reason for building programs out of function is A. that the divide-and-conquer approach facilitates program construction B. that the pre-existing functions can be used to create new programs c. the avoidance of code iteration within a program d. all of the above

D

The most concise notation to use to define function parameters x and y as double is __________. A. x,y B. x, double y C. double x,y D. double x , double y

D

Using standard library functions can be more efficient because A. They save programming time B. They are carefully written to perform optimally C.They increase program portability D. All of the above

D.

Which of the following is most closely associtated with Moore's Law A. Every year or two, the price of computers has approximately double B. Object oriented programming uses less memory than previous software development methodologies C. Demand for communications bandwidth is decreasing dramatically each year D. Every year or two, the capacities of computers have approximately doubled without any increase in price

D.

The address operator is A. && B. % C.@ D. &

D. &

Which of these is not a valid identifier? A. a_valid_identifier B.a1_valid_identifier C.a_valid_identifier_ D. 1_valid_identifier

D. 1_valid_identifier

An operator that associates from right to left is A. != B. , C. () D. ?:

D. ?:

The order in which statements are _______ is called flow of control A. Entered in a source file B. Preprocessed C. Compiled D.Executed

D. Executed

Which is not a motivation for " functionalizing" a program ? A. The dive and conquer approach makes program development more manageable B. Software reusability - using existing building blocks to create new programs C. avoid repeating code D. Execution performance - functionalized programs run faster

D. Execution performance - functionalized programs run faster

Which statement is false ? A.Counter-controlled repetition is sometimes called definite iteration B. Sentinel-controlled iteration is sometimes called indefinite iteration C. The sentinel value typically indicates " end of data" D. In counter-controlled iteration, the control variable is always incremented by 1 each time the group of instructions is performed

D. In counter-controlled iteration, the control variable is always incremented by 1 each time the group of instructions is performed

Which statement is true ? A. Operator || has a higher precedence than operator && B. In expression involving operator || making the condition that is most likely to be false the leftmost C. The logical negation operator is a binary operator D. In expression using operator && making the condition that is most likely to be false the leftmost

D. In expression using operator &&

Which statement is true ? A. with nested control statements , the inner control statement is executed in sequence after the counter control statement completes its own execution B.with nested control statements , the inner control statement is executed exactly once C. experience has shown that the most difficult part of solving a problem on a computer is converting an already correct algorithm to a C program D. a double-selection statement can be nested in an iteration statement

D. a double-selection statement can be nested in an iteration statement

Srand A. should be called before each call to rand B. should be used instead of rand to generate truly random numbers C. is unnecessary in C D. can use time as an automatically input seed value

D. can use time as an automatically input seed value

As used in int square(int); int is not a(n) _________ A. data type B.parameter type C. return type D. function prototype

D. function prototype

All of the following are reasons to use recursion except: A. an iterative solution is not apparent B. the resulting program is easier to debug C. it more naturally mirrors the problem D. it maximizes software performance

D. it maximizes

When a called function complete task, it normally A. Terminates program execution normally B. aborts program execution C. logs its results D. return to the calling function

D. return to the calling function

The ____ selection statement performs one of many different actions , depending on the value of an expression. A. if B. When C. if ... else D. Switch

D. switch

A fatal logic error is always caused by : A. not initializing variables before executing an iteration statement B.choosing a sentinel value that is also a data value C. using a counter variable in a calculation after the loop D. an attempt to divide by zero

D.an attempt to divide by zero

A linked program is often called a(n) A. chain B. librabry C. object D. executable

D.executable

If the increment of the for statement is ___ then the loop counts____ A. true, downwards B.False, downwards C.positive, downwards D.negative, downwards

D.negative, downwards

Which of the following is not a valid integer value ? A. -3 B.0 C. 2179812712 D. 1.1

D1.1

Which statement about a correct for statement with an initialization expression , a loop continuation test , an increment expression and a loop body is false? A. The initialization expression is executed only once B. The loop continuation test is evaluated each time through the loop C. The initialization is performed each time through the loop D. The increment expression is performed after the loop body

c) The initialization is performed each time through the loop.


संबंधित स्टडी सेट्स

Physical and Health Assessment Final

View Set

History of Rock & Roll: EXAM 2 Songs

View Set

Chapter 5 : Legal Fees, Timekeeping and Billing

View Set

Chapter 7 Chemistry w/ Practice Problems

View Set

Chapter 8: Application: The Costs of Taxation

View Set