Font size
WorksheetsCC 101 Final Exam
Total questions: 50
Worksheet time: 31mins
“Welcome” is a string constant.
True
False
29.85 is an integer constant.
True
False
1.2e+10 is a floating point constant.
True
False
You_1 is a valid identifier.
True
False
max temp is a valid identifier.
True
False
In this logical operator, the result is true if both operands are true; it is false in all other cases.
And
Or
Not
Type the C language syntax/code: Assign the value of 8 to the variable abc.
(a)
Type the C language syntax/code: Declare an Integer variable hours and initialize to 40.
(a)
Type the C/C++ language syntax/code: Compute the value of speed equals to distance divided by time.
(a)
Type the C/C++ language syntax/code:
Using the const keyword, declare the double variable PESO as constant value of 40.5.
(a)
In C++, this declaration allows all elements in the std namespace to be accessed in an unqualified manner (without the std:: prefix).
using namespace std;
namespace using std;
using std nameSpace;
What will be the output onscreen for this codes:
int age = 20;
int zcode = 1410;
cout << "I am " << age << "years old and my zip code is " << zcode;
(a)
Another way to write this variable declaration and initialization in C++:
int num2 = 26;
(a)
Type the C++ language syntax/code: Input value to integer variable i.
(a)
In C language:
If rate = 15, what is printed by printf("rate\n");
15
rate
The variable has the following characteristics (check all that apply)
name
value
data type
initial value
Is this declaration valid?
int j = “PQ”;
True
False
Is this declaration valid?
float p, q=0, r;
True
False
The operator precedence decides:
which operator is used first
which operator is not to be used
which operator is the fastest
In this mathematical expression:
3 * 5 + (8 + 3) / 5;
which of the following will be executed first?
3 * 5
8 + 3
25 % 3 evaluates to :
8.33
8
1
.33
Which are comparative operators? (check all that apply)
<=
>=
=
!=
Given the following C++ codes, what will be printed onscreen?
int myVar = 7;
if (myVar>=0 && myVar<7)
cout << "OK";
else
cout << "Cancel";
OK
Cancel
The following are integral data type except -
integer
character
float
Which of the following is invalid variable declaration in C/C++?
float fee=100;
int a;
double k, g=3.4;
char in=y;
What function reads data from the keyboard in C?
displayf()
printf()
read()
scanf()
What data type represents only two values – nonzero number for True and zero for False?
(a)
In C, which of the following is a correct declaration for a string of character type?
char[20] name;
char name[20];
char name=”bsit”;
char name(20);
It executed whenever none of the other case values match the value in the switch expression
break;
default
switch
case
Which of the following conversion code / format specifier is used to read or write an integer data type?
%c
%d
%f
%s
In C, what is the symbol of the address operator that can be added at the beginning of the variable to match the variable’s type to the conversion specification type?
& (ampersand)
@ (at sign)
% (percent)
# (pound sign)
What is the meaning of the header file <stdio.h>?
Stacked Input/Output
Standard Input/Output
Stated Input/Output
Steady Input/Output
Which of the following is the correct syntax to declare a PI as defined constant?
#define PI 3.1416
#define PI = 3.1416
#define PI as 3.1416
#define PI to 3.1416
Which of the following describes a positive logic of multi-way decision?
If the result is true, execute the statement(s). No else part, the false branch always goes to the next IF statement.
If the result is true, execute the statement(s). If the result is false, execute the next IF condition until the resultant is true.
If the result is true, execute the statement(s), else, a different statement(s) are/is executed.
Which is invalid for this precision modifier %4.2f?
10.99
200.00
1000.50
50000.75
What is the backslash character for horizontal tab (5 spacebar press) ?
(a)
This table shows logical relationships and lists the values that each operand can assume and the resulting value.
If Else Table
Logical Table
Pseudo Table
Truth Table
The main() function always starts and terminates with these special characters.
[
]
{
}
<
>
A logical operator that changes a true value to false and a false value to true
&& (And)
== (Equal)
! (Not)
|| (Or)
Which of the following Boolean expressions has the resulting value of True?
! True
False && True
True || False
False || False
if...else() is an example of which logic structure?
one-way decision
two-way decision
multi-way decision
It causes the program to jump out of the switch statement
break
case
default
Which two case labels are valid?
case 10:
case 10.75:
case 'g':
case >21:
Given the following C syntax, what is the output on screen?
int month = 8;
switch (month) {
case 6: printf("June");
case 7: printf("July ");
case 8: printf("August ");
case 9: printf("September ");
case 12: printf("December ");
break;
default: printf("Invalid”);
break;
}
August
August September December
December
Invalid
Another decision making structure in C/C++ aside from if, if…else, and if…else if
do...while
for
switch...case
while
Click all examples of C/C++ compiler and IDE for desktop
CodeBlocks
CC386
MinGW
Notepad
What is the filename extension of C++ program?
.c
.c++
.cpp
Which is a line comment?
/ This is a whole line comment
// This is a whole line comment
** This is a whole line comment
What is missing in these C++ codes to input string of characters?
string name, team
cout << "What's your name? ";
__________ (cin, name);
getline
get
getlines
A manipulator that can also be used to break lines aside from \n
(a)
