|
|
CS 215: UNIX C Programming
Review for Quiz 1
Go over the following questions to prepare for your quiz.
- In C, the _______ data type can hold numbers
with decimal points and the ____ data type can
hold a single character.
- int, char
- char, int
- int, float
- float, char
- Which function is used to provide keyboard
input to a computer?
- scanf()
- printf()
- enter()
- keyf()
- When the computer asks you for information
and then uses the number you type in, the
program is said to be _______________.
- interceptive
- closed
- interactive
- batched
- Data which are preset before a program is
used and which keep their values unchanged
throughout the life of the program are
called ___________.
- variables
- float point
- regular
- constants
- Data which may change or be assigned values
as a program runs are called __________.
- variables
- float point
- regular
- constants
- All of the following are variations of
forms of type int except which one?
- long
- double
- unsigned
- short
- The smallest unit of memory is called a _____.
- bite
- bin
- bit
- byte
- Which one of the following is a number
with NO fractional part?
- integer
- floating-point number
- real number
- Both a and c are correct answers.
- Which one of the following data types can
store the largest range of values?
- long double
- float
- double
- long float
- The int data type is a(n) ___________ integer.
- unsigned
- signed
- real
- unreal
- Which one of the following is an invalid
declaration of a variable of type int?
- int erns;
- int hogs, cows;
- int horses, int cows;
- None of the above are invalid declarations.
- All of the following are valid integer
constants except which one?
- 0
- -44
- 12.3
- 22
- Which one of the following conversion
specifiers is used to print a hexadecimal?
- %d
- %o
- %x
- %h
- The numeric range of a variable of type
int is ______________.
- -12767 to +12767
- -22767 to +22767
- -32767 to +32767
- -42767 to +42767
- All of the following are valid ANSI C types,
except which one?
- unsigned short
- long unsigned int
- short int
- unsigned
- All of the following are true about integer
types, except which one?
- Use short to save storage space.
- Use long to speed up calculations.
- Use unsigned for counting.
- Use short if numbers are small.
- To print a variable of type long int, which
conversion specifier is required?
- %ld
- %li
- %l
- %lf
- To print a variable of type short int, which
conversion specifier is required?
- %sd
- %d
- %hd
- Both b and c are correct answers.
- Variables of type char are actually _______
and not __________.
- characters, letters
- integers, numbers
- characters, integers
- integers, characters
- The standard ASCII code runs numerically from
0 to what?
- 64
- 127
- 256
- 512
- Which one of the following would be used
to print the sentence:
Gramps sez, " a \ is a backslash."
- printf("Gramps sez, \"a \ is a backslash."\n");
- printf("Gramps sez, \"a \ is a backslash.\"\n");
- printf("Gramps sez, \"a \ \\is a backslash.\"\n");
- printf("Gramps sez, \"a \\ is a backslash.\"\n");
- A string of characters enclosed in double
quotes in a printf() is called a character _____.
- string
- rope
- wire
- twine
- Which one of the following is a correct
scanf() statement, given the code:
char ch;
printf("Please enter a character.\n");
- scanf("%c", ch);
- scanf("%c", #ch);
- scanf("%c", $ch);
- scanf("%c", &ch);
- The exponential notation for the number
1,000,000 is _________.
- 1.0 X9
- 1.0o9
- 1.0e9
- 1.0L9
- By default, the C compiler assumes that floating point
constants are __________ precision.
- single
- double
- long single
- long double
- Which conversion specifier is required for
a variable of type double?
- %d
- %s
- %c
- %f
- C has a built-in operator called ____________
that returns the size of a variable in bytes.
- bytesize
- size
- sizeof
- size_of
- Which of the following initializations is correct?
- int apples = 56000;
- float apples = 53e45;
- char letter = "A";
- double range = 65.3;
- How many additional arguments can the
following partial printf() expect?
printf("%d cats ate %d cans of tuna\n", );
- zero
- 1
- 2
- 3
- Under ANSI C, flushing the buffer occurs when
- the buffer gets full.
- a newline character is encountered.
- there is impending input.
- All of the above are correct answers.
- Which conversion character is used to handle
the input and output of a character string?
- %c
- %s
- %f
- %d
- Which of the following functions finds
the length of a string?
- stlen()
- string()
- slength()
- strlen()
- Which character is placed at the end of
a character string?
- \t
- \0
- \e
- \s
- (A)n ____ is an ordered sequence of data
elements of one type.
- store
- subscript
- integer
- array
- In general, one call to scanf() can used with
one %s to read how many words?
- 1
- 2
- 3
- More than 3.
- When storing the string constant, "X", how many
characters are actually stored?
- 0
- 1
- 2
- 3
- Which .h header file contains the prototype
for the string length function?
- stdio.h
- str.h
- strlen.h
- string.h
- When using printf(), you cannot break a string
(move part of it to a second line) between _________.
- the quotation marks
- arguments
- commas
- Both a and b are correct answers.
- How many memory cells are required to store
the following array:
char name[40];
- 2
- 20
- 40
- 41
- Which of the following sizeof statements is(are) correct,
given the code:
char name[40];
- sizeof(name)
- sizeof name
- sizeof name[40]
- Both a and b are correct answers.
- What type of constant is pi, given the statement:
circumference = pi * diameter;
- regular
- manifest
- symbolic
- solid
- Which of the following is a valid preprocessor directive?
- #define .015 TAXRATE
- #define SIZE 12
- #define MILES = 10
- #define FEET 5280;
- Defined constants using #define are termed
______ constants.
- regular
- manifest
- symbolic
- solid
- The conversion specifier %1.3f rounds a
floating point number to how many places?
- 1
- 2
- 3
- 4
- Where does the compiler look first, given
the statement:
#include "const.h"
- The nearest system directory.
- stdio.h
- string.h
- The current directory.
- All of the following are valid printf()
conversion specifiers, except which one?
- %c
- %x
- %o
- %a
- Which conversion specifier would you use if
you wish to print 12%, where 12 is stored in
a variable of type int?
- %%d
- %d%
- d%%
- %d%%
- Which printf() flag is used to left-justify
the display of a field value?
- -
- #
- +
- L
- The conversion specifier %5.2f prints a float
which is ___ characters wide, with ___ digits
after the decimal point.
- 7, 2
- 5, 2
- 3, 2
- 5, 3
- What will be displayed, given the following statements?
#define BLURB "Outstanding!"
int main(void)
{
printf("%15.5s\n", BLURB);
}
- Outst
- BLURB
- "Outs
- Outstanding
- In ANSI C, what value is returned
by the printf() function?
- The letters inside the double quotes.
- The length in bytes of the displayed message.
- The number of characters it printed.
- No value is returned by printf().
- The scanf() function converts ____ input
into various forms.
- integers
- floating-point numbers
- strings
- All of the above are correct.
- If you use scanf() to read a string into
a character array
- precede the variable name with an &.
- precede the variable name with a #.
- precede the variable name with a %.
- don't use &, #, or %.
- If you use a field width with scanf(),
the function halts
- at the field end.
- at the first whitespace.
- Both a and b are correct.
- A field width cannot be used with scanf().
- In ANSI C, what value is returned by the
scanf() function?
- The number of characters read.
- The length in bytes of the letters entered.
- The letters entered at the keyboard.
- No value is returned by scanf().
- The abbreviation EOF stands for
- error on float
- end of file
- error on file
- end of float
- The * modifier used with scanf() causes
the function to ___ corresponding input.
- add
- concatenate
- skip over
- merge
- All of the following are scanf() conversion
specifiers, except which one?
- %c
- %f
- %r
- %s
- With printf(), which one of the following pads
the field width with leading zeros instead of spaces?
- %010d
- %#10d
- %%10d
- %*10d
- With printf(), which one of the following
informs the C program to specify the field
width of a variable?
- %0d
- %#d
- %%d
- %*d
|