(CPS 188) CPS188 FINAL EXAM STUDY WITH COMPLETE
SOLUTIONS!!
#include <stdio.h> - ANSWER header file library
adds functionality to c programs
what is the error code in this program?
printf("Hello World!") - ANSWER error: expected ';' before 'return'
printf - ANSWER used to output values or print text in C
When working with text, they must be enclosed inside __ marks. - ANSWER when
working with text, they must be enclosed inside double quotation marks.
what is the output of the sequential print statements such
printf("Hello World!");
printf("I am learning C."); printf("And it is awesome!");
return 0; - ANSWER statements are printed with no errors, however a new line is not
inserted at the end of the output
What character is used to insert a new line - ANSWER \n
Two __ characters after each other will create a blank line - ANSWER Two \n\n
characters after each other will create a blank line
escape sequence \t - ANSWER creates a horizontal tab
,escape sequence \\ - ANSWER inserts a backslash character
escape sequence \" - ANSWER inserts a double quote character
function int - ANSWER stores whole numbers without decimals
function float - ANSWER stores floating point numbers, with decimals, such as 19.99
function char - ANSWER stores single characters
surrounded by single quotes
to create a variable, specify the __ and assign it a __ - ANSWER to create a variable,
specify the type and assign it a value
what is a format specifier? - ANSWER a placeholder for the variable value
if you assign a new value to an existing variable, it will __ the previous value - ANSWER
overwrite
What is the output of this function?
int myNum = 15;
int myOtherNum = 23;
myNum = myOtherNum;
printf("%d", myNum); - ANSWER 23 as the values of myOtherNum was assigned to
myNum
what is this code doing?
, int myNum = 15;
int myOtherNum;
myOtherNum = myNum;
printf("%d", myOtherNum); - ANSWER copying a value into an empty variable
names can contain __, __, and __. - ANSWER Names can contain letters, digits and
underscores
names must begin with a __ or an __ - ANSWER Names must begin with a letter or an
underscore (_)
names are __ - ANSWER names are case-sensitive
names cannot contain __ or __ __ - ANSWER Names cannot contain whitespaces or
special characters
fill in the code
int length = 4;
int width = 6;
int area;
// Calculate the area of a rectangle
printf("Length is: %d\n", length);
printf("Width is: %d\n", width);
printf("Area of the rectangle is: %d", area); - ANSWER area = length * width;
what are the format specifiers for int - ANSWER %d %i
SOLUTIONS!!
#include <stdio.h> - ANSWER header file library
adds functionality to c programs
what is the error code in this program?
printf("Hello World!") - ANSWER error: expected ';' before 'return'
printf - ANSWER used to output values or print text in C
When working with text, they must be enclosed inside __ marks. - ANSWER when
working with text, they must be enclosed inside double quotation marks.
what is the output of the sequential print statements such
printf("Hello World!");
printf("I am learning C."); printf("And it is awesome!");
return 0; - ANSWER statements are printed with no errors, however a new line is not
inserted at the end of the output
What character is used to insert a new line - ANSWER \n
Two __ characters after each other will create a blank line - ANSWER Two \n\n
characters after each other will create a blank line
escape sequence \t - ANSWER creates a horizontal tab
,escape sequence \\ - ANSWER inserts a backslash character
escape sequence \" - ANSWER inserts a double quote character
function int - ANSWER stores whole numbers without decimals
function float - ANSWER stores floating point numbers, with decimals, such as 19.99
function char - ANSWER stores single characters
surrounded by single quotes
to create a variable, specify the __ and assign it a __ - ANSWER to create a variable,
specify the type and assign it a value
what is a format specifier? - ANSWER a placeholder for the variable value
if you assign a new value to an existing variable, it will __ the previous value - ANSWER
overwrite
What is the output of this function?
int myNum = 15;
int myOtherNum = 23;
myNum = myOtherNum;
printf("%d", myNum); - ANSWER 23 as the values of myOtherNum was assigned to
myNum
what is this code doing?
, int myNum = 15;
int myOtherNum;
myOtherNum = myNum;
printf("%d", myOtherNum); - ANSWER copying a value into an empty variable
names can contain __, __, and __. - ANSWER Names can contain letters, digits and
underscores
names must begin with a __ or an __ - ANSWER Names must begin with a letter or an
underscore (_)
names are __ - ANSWER names are case-sensitive
names cannot contain __ or __ __ - ANSWER Names cannot contain whitespaces or
special characters
fill in the code
int length = 4;
int width = 6;
int area;
// Calculate the area of a rectangle
printf("Length is: %d\n", length);
printf("Width is: %d\n", width);
printf("Area of the rectangle is: %d", area); - ANSWER area = length * width;
what are the format specifiers for int - ANSWER %d %i