C How to Program Chapter 2
The conversion specifier ______ is used in a scanf format control string to indicate that an integer will be input and in a printf format control string to indicate that an integer will be output
%d
State that a program will calculate the product of three integers
a) /* Calculate the product of three integers */
Define the variables x, y, z and result to be of type int.
b) int x, y, z, result;
Prompt the user to enter three integers
c) printf( "Enter three integers: " );
Read three integers from the keyboard and store them in the variables x, y and z
d) scanf( "%d%d%d", &x, &y, &z );
Whenever a new value is placed in a memory location, that value overrides the previous value in that location. This process is said to be______ .
destructive
Compute the product of the three integers contained in variables x, y and z, and assign the result to the variable result
e) result = x * y * z;
Print "The product is" followed by the value of the integer variable result.
f) printf( "The product is %d\n", result );
The _____ statement is used to make decisions.
if
If number is not equal to 7, print "The variable number is not equal to 7."
if ( number != 7 ) { printf( "The variable number is not equal to 7.\n" ); }
Define the variables c, thisVariable, q76354 and number to be of type int
int c, thisVariable, q76354, number;
The _______ begins the body of every function and the _____ ends the body of every function.
left brace, right brace
Every C program begins execution at the function____.
main
The escape sequence \n represents the _____ character, which causes the cursor to position to the beginning of the next line on the screen.
newline
When a value is read out of a memory location, the value in that location is preserved; this process is said to be ____.
nondestructive
The _______ standard library function displays information on the screen
printf
Prompt the user to enter an integer. End your prompting message with a colon (:) followed by a space and leave the cursor positioned after the space
printf( "Enter an integer: " );
Print the message "This is a C program." on two lines so that the first line ends with C
printf( "This is a C \n program.\n" );
Print the message "This is a C program." on one line
printf( "This is a C program.\n" );
Print the message "This is a C program." with each word on a separate line.
printf("This\nis\na\nC\nprogram.\n" );
Print the message "This is a C program." with the words separated by tabs
printf("This\tis\ta\tC\tprogram.\n" );
The ____Standard Library function is used to obtain data from the keyboard
scanf
Read an integer from the keyboard and store the value entered in integer variable a
scanf( "%d", &a );
Every statement ends with a(n)
semicolon