Final Exam prep Flashcards
We can use the g++ compiler to read the high level code and store a translation in another file, the executable
True?
False?
True
Words in the C++ programming language are case insensitive
True?
False?
False
The ______ of a program language are its own precise grammar rules
a: syntax
b: semantics
c: execution
d: compilation
a: syntax
The ______ of a program represent the actual meaning of a segment of source code
a: indentation
b: semantics
c: syntax
d: code blocks
b: semantics
The assignment operator = allots the value of the right-side expression to the left operand
True?
False?
True
What is the final value of the variable b after the program is executed?
#include <cstdio></cstdio>
int main()
{
int a = 4, b = 0;
b = (a * 3) + 2;
printf(“%d”, b);
}
a: 18
b: 14
c: 0
d: 20
b: 14
Assume x = 2 and y = 3. What is the output of the following statement?
printf(“x=%d”, y);
a: y = 2
b: x = 2
c: x = 3
d: y = 3
c: x = 3
include <cstdio></cstdio>
What is the final value of the variable Pi after running the following program?
int main()
{
int age;
float myNumber;
int y = 3, z = 4;
float x = 0;
const float Pi = 3.1416;
int r = 7;
float area = 0;
Pi = Pi + 4
}
a: 0
b: None of the options listed. The program will not compile
c: 7.1416
d: 3.1416
b: None of the options listed. The program will not compile.
Note: the reason that the program will not compile is that 4 is not recognized by the program.
Note: declaration of a const means you cannot manipulate it
What is the output of the following program?
#include <cstdio></cstdio>
int main()
{
int a = , b = 3;
//b = a + 1;
//b = a * a;
b = b + a;
b = b * b;
//b = b + 2;
printf(“%d”, b);
}
a: 11
b: 0
c: 9
d: 3
Following up question: what is the purpose of %d?
b: 9
Answer for the following up question:
%d
prints the value of the int variable num in decimal number system
%o
prints the value of the int variable num in octal number system
#include <cstdio></cstdio>
int main()
{
//printf(“hello world!”);
//printf(“this is a second line”);
printf”this is the a third line”);
//printf(“Programming is fun!”);
}
a: hello world!
b: this is a third line
c: Programming is fun!
d: this is a second line
b: this is a third line
To use a funcion effectively, we only need to know:
_ its name
_ the type of data value (if any) it returns
True?
False?
False
return( printf(“%d”, ‘t’));
a: void
b: int
c: char
d: none of the options is correct
b: int
What would be the value assigned to x?
int x = increaseMe(increaseMe(increaseMe(3)))%7?
————————–
int increaseMe(int x)
{
int y = x + 1;
return(y);
}
a: 0
b: 1
c: 6
d: 7
c: 6
Functions are requied to have parameters.
True?
False?
False
What would be the value assigned to v?
int v = increaseMe(multiplyUs(6,5));
————————
int increaseMe(int x)
{
int y = x + 1;
return(y);
}
int multiplyUs(int n1, int n2)
{
return(n1/n2);
}
a: 31
b: 2
c: 1
d: 0
b: 2
printf(“%d”, ‘t’);
a: none of the options is correct
b: a floating point number
c: a number
d: char
c: a number
float multiplyUs(float n1, float n2)
{
float result = n1 / n2;
return(‘m’);
}
void printSomethin(int number)
{
cout «_space;increaseMe(number) «_space;endl;
}
True?
False?
False
printf returns a count of how many characters it displayed
True?
False?
True
When a return statement runs, the function immediately ends and sends back the return value
True?
False?
True
scanf returns a count of how many characters were assigned to a variable
True?
False
False
a: if(age > 10 || userDept == 7 && userDept == 13){}
b: if(age > 10 || (userDept == 7 && userDept == 13)){}
c:if(age > 10 && userDept == 7 && userDept == 13){}
d:if(age > 10 && (userDept == 7 || userDept == 13)){}
d:if(age > 10 && (userDept == 7 || userDept == 13)){}
int main()
{
int a = 1;
switch(a)
{
case 1:
cout«“One”;
case 2:
cout«“Two”;
case 3:
cout«“Three”;
default:
cout«“Default”;
}
}
a: Three
b: Default
c: One
d: None of the options listed
d: Two
d: None of the options listed
a flag is a Boolean variable signaling that some condition exists in the program. When the flag is set to false it indicates the condition does not exist. When the flag is set to true it indicates that the condition does exist.
True?
False?
True
int main()
{
if(5 == -1)
{
cout«“M”;
}
else
{
cout«“T”;
}
}
a: M
b: The code will not compile
c: None of the options listed
d: T
d: T