Program C

Ace your homework & exams now with Quizwiz!

The operator that tests for equality in C is?

= + (x)== * &

A do-while loop repeats until a test is true.

True (x)False

A for loop always repeats a specific number of times.

True (x)False

Which of the following establishes a connection to a file?

fwrite( ) fname( ) fprintf( ) (x)fopen( ) FILE *

A function used to produce output is:

main string.h scanf (x)printf return

Which of the following indicates a null character:

null (x)'\0' '0' '\n' NULL

Conditional statements are useful in programming:

(x)to allow programs to make decisions if we don't know what we're doing because nothing else uses logical values they aren't, loops do the same thing

The for statement for(i=0; i<10; i++) printf( "i=%d\n", i); will execute the printf( ):

9 times 11 times 0 times, since i=0 (x)10 times only once

Which of the following can help us program?

The compiler (x)All of these Compiler options Header files and libraries The preprocessor

Compiling makes your code execute.

True (x)False

IPO does not apply to functions since a function would not have these three parts.

True (x)False

In a switch, a test expression determines which case is executed.

True (x)False

Including a header file gives access to C library routines

True (x)False

A function produces output within a program thru:

a void return type (x)a return value parameters printf( ) scanf( )

Conditional statements and loops generally have tests written with:

arithmetic operators assignment operators compound assignment operators the modulus operator (x)logical and relational operators

The C standard libraries qsort( ) algorithm:

can sort any array requires a function name as a parameter requires two addresses can only sort structures (x)All but the previous

Which of the following does not produce conditional code?

if if/else switch( ) ? : (x)all do

A data tye used to store numbers with fractional parts is:

main (x)float string int char

Pointers and arrays are related because:

pointers always track sets of values of scanf and the & (x)both work with addresses they aren't, * and [ ] are unrelated they can both hold int & float

Which of the following is the destination for printf( )

screen keyboard (x)standard output computer memory

C bit operators give us:

the ability to impact individual bits on a computer. operators like logical AND, OR and NOT, but at the bit level. shift operators to shift bit patterns to the left or the right. the ability to combine bit patterns using AND, OR, and XOR all but the previous answer (x)all of the four answers

An advantage to using an array is:

there is no advantage, usevariables functions only use arrays arrays are always strings you can use better names (x)it can closely match yourproblem

Structures have the advantage of:

treating several pieces of data as one. allowing several types to be combined into one. creating a new type that the compiler will recognize. making the code more closely match the problem. (x)all of these.

A while loop repeats:

while a test is false a specific number of times until a test is true 5 times (x)while a test is true

An array allows a programmer to:

write more confusing code create a storage location easily create a large set of storage locations easily access a large set of storage locations (x)both of the previous answers

Which of the following produces output?

#include ; scanf ( ) arithmetic operators (x)printf ( )

The C definition of a string is:

%c C source code a character an array (x)a set of characters ending in null

Which of the following indicates a newline in the C language:

%d (x)\n conversion specifier double quotes ;

A symbol used to access the value at an address is:

&& & * (x)both * and [ ] [ ]

Which of the following are relational operators?

&& || ! (x)< > == != + - * /

The symbol used to produce the address of a variable is:

(x)& ++ * && ->

Which of the following are logical operators?

(x)&& || ! < > == != + - * /

How many times will the following loop repeat? for(i=0; i<10; i=i+2) printf("i = %d \n", i);

(x)5 times 11 times, because it starts at zero 10 times 9 times, its < 10

A function can be passed to another function as a pointer.

(x)True False

A pointer is a variable used to store an address.

(x)True False

Which of the following produces processing?

(x)arithmetic operators ; #include printf ( ) scanf ( )

Which of the following is specifically for binary I/O?

(x)fwrite( ) fname( ) fprintf( ) fopen( ) FILE *

The compiler can do more for the programmer with:

(x)structs const -Wall all of these

The const keyword:

Question options: has no use with pointers, since pointers aren't the actual data. places variables in ROM - Read Only Memory. (x)enlists the compiler to prevent changes to a variable. cannot be used on function parameters.

Conditional statements are not needed in well written

True (x)False

Conversion specifiers are mis-named; they really have nothing to do with conversion.

True (x)False

Dividing integers and dividing floating-point values always produces the same result

True (x)False

Functions are rarely used in a C program

True (x)False

It is wrong to think of a function as a small/sub-program.

True (x)False

None of the C arithmetic operators resemble their mathematical representations.

True (x)False

Since comments are not required, we should not use them.

True (x)False

Structures and arrays are the same thing since they are both sets of storage locations.

True (x)False

The C scanf( ) function always reads from the keyboard.

True (x)False

The compiler generates error messages to annoy the programmer.

True (x)False

The number of values that can be stored in an array of size n is really n-1.

True (x)False

The term to indicate no inputs or outputs to/from a function is null.

True (x)False

There is no difference between single quotes ' ' and double quotes " " in C

True (x)False

qsort( ) can only sort sets of fundamental datatypes, like int, char, and double.

True (x)False

A difference between integer and floating-point arithmetic is:

all arithmetic is floating point there is no integer arithmetic (x)integer is faster binary cannot do floating-point they are equivalent

The order that operators are evaluated in a C program is:

always from right to left (x)based on precedence always from left to right

Accessing a location in an array requires:

an index value the array name another variable arrays require all locations to be accessed at once (x)both an array name and an index value

A data type used to store integers is:

main string (x)int float char

Library files provide for:

more reliable code. faster compiling. easier access to commonly used code. easier modification of commonly used code. (x)All the above. All but "faster compiling".

Which of the following is the default input source in a C program?

printf scanf %d (x)standard input getchar

Which of the following produces input?

printf ( ) (x)scanf ( ) arithmetic operators ; #include

The translation of C langage to machine language is called:

programming C++ editing (x)compiling saving

What does "conditional execution" provide to a programmer?

random numbers access to boolean data (x)more flexible/robust programs math libraries access to I/O

A for loop:

repeats like an if (x)is basically a while loop repeats until a test is true always runs 5 times can't produce repetition

Information passed into a function is called a:

return value prototype (x)parameter .h file function body

Tradeoffs between text and binary I/O include:

speed vs. size. (x)human readable vs. machine readable. reading and writing. all I/O is basically text.

C is able to handle strings well because:

strings are always a fixed length the computer always knows a string's length (x)there is always a null character ending a string strings are like arrays, they are a fixed length

The = operator in C means:

test two values for equality do arithmetic with two values (x)assign a value to a variable print a value create a variable

An array is:

the same as a variable the same as a function (x)a named set of storage locations only able to store integers

Strings and arrays are related because:

they aren't, arrays are for numeric data only all characters are stored in arrays (x)both deal with sets of values arrays only hold int & float data all arrays store characters

A while loop repeats as long as the test is true.

(x)True False

The C preprocessor cannot do which of the following?

use #define to automatically modify source use #include to add header files (x)provide access to C libraries it can do all of the above it cannot do any of the above

Input is sent to a function within a program thru:

void a return value (x)parameters printf( ) strcpy( )

Conditional statements make programs more flexible, since they can do different things at different times.

(x)True False

In C, the true/false tests are generally constructed using relational and logical operators

(x)True False

Looping and arrays allow a programmer to easily process large quantities of data.

(x)True False

Looping causes a program to repeat instructions

(x)True False

Looping structures are useful because they can perform a lot of work with a very small amount of code.

(x)True False

The compiler generates error messages to tell the programmer how to fix their code.

(x)True False

The main() function is the starting point of a C program.

(x)True False

Write access mode w+ allows write and read access.

(x)True False

A library file:

(x)contains compiled code that our programs can use is included by the preprocessor is a file like stdio.h, or string.h

Which of the following are looping structures in C?

for while do-while if (x)all except if all except do-while

The process of building a program from C code is best described as:

gcc -c Edit, compile and run Compile, link and run (x)Preprocess, compile, link

Which of the following is NOT an input function?

getchar scanf (x)printf gets

The C programming language:

has been around a long time is still popular produces fast programs (x)all of the above

Which of the following are legitimate pointer declarations?

void * int * int & (x)All but int &.

Which of the following is roughly equivalent to an if statement in C?

while scanf switch ? : for (x)both switch and ? :

A variable is:

written in single quotes (x)a named storage location always int main written in double quotes


Related study sets

Chapter 5: Interviewing Techniques

View Set

Unit Two Chapter 6. Microbial Metabolism: Fueling Cell Growth

View Set

Windows Server II Chapter 10 Managing Group Policy

View Set

IB Biology HL Unit 1 essay questions w/ markscheme

View Set

Chapter 7 - Risk & Return - FIN 3290

View Set