Plus Two Computer Application Chapter Wise Previous Questions Chapter 1 Review of C++ Programming

Kerala Plus Two Computer Application Chapter Wise Previous Questions Chapter 1 Review of C++ Programming

Plus Two Computer Application Review of C++ Programming 1 Mark Important Questions

Question 1.
_______ is an exit control loop. (MAY-2016)
a) for loop
b) while loop
c) do-while loop
d) break
Answer:
do-while loop

Question 2.
Which among the following is an Insertion Operator? (MARCH-2016)
a) <<
b) >>
c) <
d) >
Answer:
a) <<

Question 3.
Which among the following is equivalent to the statement series b=a, a = a +1 ? (MARCH-2017)
a) b + = a
b) b = a++
c) b = ++a
d) b + = a + b
Answer:
b) b = a++

Question 4.
A ______ statement in a loop force the termination of that loop. (MARCH-2017)
Answer:
break

Question 5.
_______ operator is the arithmetic assignment operator. (MAY-2017)
a) >>
b) ==
c) +=
d) =
Answer:
c) +=

Plus Two Computer Application Review of C++ Programming 2 Marks Important Questions

Question 1.
How does a ‘goto’ statement work? (MAY-2016)
Answer:
The execution of a program is sequential but we can change this sequential manner by using jump statements. The jump statements are
1) goto statement By using goto we can transfer the control anywhere in the program without any condition. The syntax is goto label;
Eg.
# include<iostream>
using namespace std;
int main()
{
float a,b;
cout<<“Enter 2 numbers”;
cin>>a>>b;
if(b==0)
goto end;
cout<<“The quotient is “<< a/b;
return 0;
end:
cout<<“Division by zero error”;
}

Question 2.
What are the main components of a looping statement ? (MARCH-2016)
Answer:
The main components are initialization expression, test expression, update expression and looping body
eg: for (i=1; i<=10; i++)
cout << i;

Question 3.
Identify the following C++ tokens. (MAY-2017)
a) “welcome”
b) int
c) >=
d) ++
Answer:
a) “welcome” String Literal
b) int-Keyword
c) >= Operator
d) ++-: Operator

Plus Two Computer Application Review of C++ Programming 3 Marks Important Questions

Question 1.
Explain switch statement with an example (MAY-2016)
Answer:
cin >> pcode;
switch (pcode)
{
case ‘C’:
cout <<“Computer”;
break;
case ‘M’:
cout << “Mobile Phone”;
break;
case ’L’:
cout << “Laptop”;
break;
default:
cout << “lnvalid code”;

Question 2.
Rewrite the following C++ code using ‘switch’ statement (MARCH-2017)
cin >> pcode;
if (pcode == ‘C’)
cout << “Computer”;
else if (pcode == ‘M’)
cout<<“Mobile Phone”;
else if(pcode == ‘L’)
cout<<“Laptop
else
cout<<“lnvalid code”;
Answer:
cin >> pcode;
switch(pcode)
{
case ‘C’:
cout << “Computer”;
break;
case ‘M’:
cout << “Mobile Phone”;
break;
case ’L’:
cout << “Laptop”;
break;
default:
cout << “lnvalid code”;

Question 3.
How do continue and break statement differ in a loop? Explain with an example. (MARCH-2016)
Answer:
Break is used to terminate a loop. But continue is used for skipping (by passing) a part of the code, eg: for (i=1, i<10; i++)
{
if (i%2==0) continue; cout<<i << “, “;
}
Here the output is 1,3, 5, 7, 9
eg: for (i=1; i<10; i++)
{
if (i% 2==0) break;
cout<<i<<“,”;
}
Here the output is 1, that is the loop is quit when i=2.

Question 4.
Explain break and continue statements with example. (MAY-2017)
Answer:
break statement:- It is used to skip over a part of the code i.e. we can premature exit from a loop such as while, do-while, for or switch, continue statement:- It bypasses one iteration of the loop.
break statement:- It is used to skip over a part of the code i.e. we can premature exit from a loop such as while, do-while, for or switch.
Syntax :
while (expression)
if (condition) break;
}
Eg.
#include<iostream>
using namespace std;
int main()
{
int i=1;
while(i<10)
{
cout<<i<<endl;
if(i==5)
break;
i++;
}
}
The output is
1
2
3
4
5
continue statement:- It bypasses one iteration of the loop.
Syntax:
while (expression)
{
if (condition) break;
}
Eg.
#include<iostream>
using namespace std;
int main()
{
int i=0;
while(i<10)
{
i++;
if(i==5) continue;
cout<<i<<endl;
}
}
The output is
1
2
3
4
5
6
7
8
9
10

Plus Two Computer Application Chapter Wise Previous Questions and Answers

Leave a Comment