NEW
Font size
WorksheetsDFC20113 Programming Fundamentals Set B
Total questions: 30
Worksheet time: 3600secs
"Error that occur when a program with no syntax errors asks the computer to do something that the computer is unable to do."
Select the CORRECT answer based on the statement above.
Run-Time Error
Compile Error
Syntax Error
Logic Error
Select the symbol used at the beginning of a comment.
( )
/ /
< >
" "
Identify the valid variable.
MY AGE
4_stu
while
area
"A location in the memory that stores data that never changes during the execution of the program." Choose the CORRECT answer for the statement.
Constants
Variables
Identifiers
Keywords
Identify the output from the program below.
int main()
{
int num1=20, num2=30;
int ans = num1+num2;
cout<<ans;
}
40
50
30
20
There are FIVE arithmetic operators and every operator have their own precedence of the arithmetic operators.
* , / , % , + , -
+ , / , % , - , *
- , + , % , / , *
+ , % , - , / , *
Consider the code program below. Fill in the blank with the appropriate answer.
void main()
{
int A=10;
A=A+100;
cout<<"Value of A is :"<< _________;
}
A
Value
<<
A=A=100
Identify which is NOT the type of looping control structure.
For
If...else
While
Do..while
Identify the number of "do..while" loop which are guaranteed to loop.
3
2
1
0
Choose the CORRECT syntax for an if..else statement.
if {condition} else
if {condition} else (true statement)
if (condition) {true statement} else {false statement}
if else (condition) {true statement} {false statement}
Identify the number of repetitions that will occur for the following looping control structure in statement below
for (int count=0; count<=20; count++)
18
19
20
21
Identify the CORRECT output for the program below
main()
{
for (int a=1 ; a<=3 ; a++)
{
cout<<endl;
for (int b=1 ; b<=a+0; b++)
cout<<"\t";
}
}
*
**
***
***
**
*
**
***
*
*
*
*
Choose the control structures that have the same concept with the sample code below.
int main()
{
int n=4;
while (n<=3)
cout<<"Value of :\n"<<n;
n++;
}
for
do...while
nested if
switch case
Determine the output for the sample code below.
x=1;
switch (x)
{
case 0: cout<<"You";
case 1: cout<<"I am";
case 2: cout<<"Clever";
}
You
I am
YouClever
IamClever
Identify the output for the sample code below.
int i=10; j=10;
while(i<=10)
{
while(j<=10)
{
cout<<i*j<<endl;
j=j+1;
}
i=i+1;
}
0
10
100
1000
Determine how to read the third element in an array 'height'.
height[2]
height[1]
height[3]
height[2+1]
Based on the structure declarationbelow, identify the members name for car structure.
struct car
{
char model[50];
float price;
}persona, exora;
persona, exora
model, price
char, float
char model
Based on the two dimensional array statement below, what is the value of Rectangle[1][3]?
int Rectangle[2][5]={4,3,5,6,7,8,9,10,14,12}
8
6
14
12
Choose the value in the variable cgpanum after statement below is executed.
int cgpa={3.5,2.5,2.8,3.2,3.6};
cgpanum=cgpa[4];
2.5
2.8
3.2
3.6
Determine the output for the code segment below.
int a[5][2]={{0,3},{1,2},{2,4},{7,6},{4,8};
cout<<a[3][0];
4
2,4
7
7,6
Based on the segment code below, interpret the statement to display the value of Total.
float Total=50.5;
float Tptr;
Tptr=&Total;
cout<<Tptr;
cout<<&Tptr
cout<<*&Total;
cout<<*Tptr;
Identify the output if the code below is executed.
char *ptr;
ptr=hello;
cout<<*ptr;
first letter
entire string
it is a syntax error
last letter
Analyze the segment code below and detect the suitable line code which hold the value of num2.
int num=2,num2;
int *pnum;
pnum=#
num2=num1;
cout<<num;
num2=*pnum;
*num1=num2;
num2-*num1;
&num1=*pnum
Identify the program execution in the beginning of C++ programming.
main function
calling function
definition function
user-defined function
Select the declaration of prototype Display function which does not return any value and receive two float type parameters.
void Display();
float Display();
float Display(float);
void Display(float,float);
Identify a VALID function called.
Mark(int,int);
Mark(w,z);
Mark(int w, int y);
int Mark (int w=4, int y=2_;
Identify the function prototype for function definition in statement below.
void addition (int a, int b)
{
cout<<a+b;
}
void addition (int, int)
void addition (void, void)
int addition (int, int)
int addition (void, void)
Choose the CORRECT output based on statement below.
void duplicate (int &a, int &b, int &c)
{
a*=2;
b*=2;
c*=2;
}
int main()
{
int x=1, y=3, z=7;
duplicate(x,y,z);
cout<<"x="<<x<<"y="<<y<<"z="<<z;
return 0;
}
x=2 y=6 z=10
x=2 y=6 z=14
x=1 y=3 z=7
x=3 y=5 z=9
Choose the CORRECT way to initialize and assign a value to a pointer.
int *a;
int total=10;
a=&total;
int &a;
int total=10;
a=*total;
int a;
int total=10;
*a=total;
int &a;
int total=10;
total=*a;
Determine the output based on the program given below.
void main() {
int firstnum, secondnum;
int *myp;
myp=&firstnum;
*myp=15;
myp=&secondnum;
*myp=25;
cout<<firstnum<<" , "<<secondnum<<endl;
}
25,15
15,15
15,25
25,25
