12th Standard CBSE Syllabus & Materials
12th Standard CBSE
CBSE 12th Economics Government Budget and the Economy Previous year Question Papers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Computer Science Interface Python with MySQL - New Previous year Question Papers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Computer Science Database Concept - New Previous year Question Papers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Computer Science Data Communication - New Previous year Question Papers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Computer Science Data Structures - New Previous year Question Papers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Computer Science Functions - New Previous year Question Papers Study Material - QB365 Set A

Published on: 27/07/2018
In this question paper, some of the important one mark, two and five marks questions from the chapter Review Of C++ are covered. The questions are prepared from the book back and previous year questions.
Students, subscribe and get plenty of question paper with answer key. For subscription please click here.
Download CBSE Class 12th Standard CBSE Computer Science question papers, sample papers, important questions, and previous year solved papers in PDF format. Get free study materials, NCERT solutions, and exam preparation resources for Class 12th Standard CBSE Computer Science
Questions + Answers key
Take MCQ Computer Science Test

1.
Rewrite the following program after removing the syntactical errors(if any). Underline each correction.
#include<iostream.h>
typedef char Text(80);
void main()
{
Text T="Indian";
int Count=strlen(T);
cout<<T<<'has'<<Count<<'characters'<<endl;
}
2.
What is the benefit of using function prototype for a function? Give a suitable example to illustrate it using a C++ code.
3.
What is the difference between actual and formal parameter? Give a suitable example to illustrate using a C++ code
4.
What will be the printed on the console by the code below?
#include<iostream.h>
#include<conio.h>
void main()
{
int x=9, y=7, z=2, k=0, j=0;
double m=1.1;
clrscr();
if(x>y)
{
if(y>z&&y>k)
{
m - -;
}
else
{
k++;
}
}
else
{
j++;
}
cout<<"m="<<m<<endl;
}
5.
What is wrong with the following while loop and how does the correct ones look like?
int c=1;
while(c<100)
cout<<c<<"\n";
c++;
6.
Find the output of the following program:
#include<iostream.h>
void main()
{
int A=5,B=10;
for( int I=1; I<=2;I++)
{
cout<<"Line 1="<<A++<<"&"<<B-2<<endl;
cout<<"Line 2="<<++B<<"&"<<A+3<<endl;
}
}
7.
How precedence of assignment operators related to other operators? What is their associativity?
8.
Identify the errors in the following code segment:
include<iostream.h>
Main();
{
Float x, y;
cout<"Enter two numbers";
cin>>a>>b
cout<<' The numbers in reverse order are '<<b,a;
}
9.
What is the purpose of using a typedef command in C++? Explain with suitable example.
10.
Write the output of the following program.
Void main()
{
int x=5, y=5;
cout<<x--;
cout<<",";
cout<<--x;
cout<<",";
cout<<y--<<","<<--y;
}
11.
What is the difference between automatic conversion and type casting? Also, give a suitable C++ code to illustrate both
12.
An unsigned int can be twice as large as the signed int. Explain how?
13.
List the output of the program below.In other words, everytime there is a cout statement, list the values that will appear on the screen.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
for(int i=1;i<3;i++)
for(int j=1;j<=5;j+=2)
cout<<i<<"*"<<j<<"="<<i*j<<endl;
double a=1;
while(a<32)
a*=2;
cout<<"a="<<a<<endl;
i=8,j=3;
int k=i/j;
double b=i/j;
double c=((double)i/(double)j);
cout<<"Now k="<<k<<", b="<<b<<", c="<<c<<endl;
getch();
}
14.
Write a program in C++ to print first 10 multiples of an integer N, where N is to be entered by user:
15.
Which C++ header file(s) are essentially required to be included to run/execute the following C++ source code? (Note: Do not include any header file which is/are notrequired).
void main()
{
char STRING[]= " Something";
cout<<"Balance Characters:";
cout<<160-strlen(STRING)<<endl;
}
16.
What is the effect of absence of break in switch-case statement?
17.
How is an entry controlled loop different from exit controlled loop?
18.
Which value of x will be printed in following case and why?
int x=9;
void main()
{
int x = 10;
cout<<x;
}
19.
Evaluate the following C++ expression for x=10, y=5 and z=11
(x==y)||(!(z==y))&&(z<x)
20.
If v is an identifier of int type and is holding value 255. Is the following statement correct?
char code = v;
21.
Write the difference between = and ==
22.
How 'I' operator is different from '%' operator?
23.
Give the output of the following program:
int a=44;
cout<<a++<<"\t"<<a<<"\n"<<++a;
cout<<endl<<a<<endl;
24.
Generally there are four data types, each of which can be signed or unsigned.Write names of all four data types.
1.
#include<iostream.h>
#include<string.h>
typedef char Text[80];
void main()
{
Text T="Indian";
int Count=strlen(T);
cout<<T<<"has"<<Count<<"characters"<<endl;
}
2.
The function prototype serves to ensure that calls to the function are made with the proper number and types of arguments.In the case of function overloading the different prototypes serve to distinguish which version of the function to call.
The compiler will complain with an error if no function prototype is found for any particular call to a function.
e.g.Program to illustrate use of function prototyping.
#include<iostream.h>
int square(int); //Function prototype
int main()
{
for(int x=1;x<=10;x++)
cout<<square(x)<<" ";
cout<<endl;
return 0;
} //Function definition
int square(int y)
{
return(y*y);
}
3.
Differences between actual and formal parameters are as follows:
| Actual Parameter | Formal Parameter |
|---|---|
| Parameters provided at the time of function calling are called actual parameters. | Parameters provided at the time of function definition are called formal parameters. |
| These parameters contain actual values. | These parameters are simple variable declarations.i.e. they do not contain actual values. |
e.g. Program to swap the value of two numbers to show actual and formal parameters.
#include
#include
void swap( int n1,int2) //Formal Parameters
{
int temp=n1;
n1=n2;
cout<<"Values of num1 and num2 after swapping:";
cout<
void main()
{
int num1,num2;
clrscr();
cout<<"Enter two numbers: ";
cin>>num1>>num2;
swap(num1,num2); //Actual parameters
getch();
}
4.
m=0.1
k=0
j=0
5.
In this loop, there are not brackets surrounding the code block of the while loop. Therefore, only the line immediately following the while statement repeats. Since, that line does not modify counter, its value will always be 1. Hence, it's from infinite loop. To fix, we need to add grouping brackets around the lines after the while loop, i.e.
while(c<100)
{
cout<<c<<"\n";
c++;
}
6.
Line 1=5&8
Line 2=11&9
Line 1=6&9
Line 1=12&10
7.
The operators are hierarchically arranged according to their precedence or we can say according to the order of evaluation. Assignment operators like =, +=, -=, #=, /=, etc., have a lower precedence than any of the other operators. Therefore, unary operations, arithmetic operations, relational operations, equality operations and logical operations are all carried out before assignment operations.
Associativity means the order in which consecutive operators within the same precedence group are carried out. The assignment operations have a right to left associativity, which means that the compiler starts on the right of the expression and works towards.
8.
(i) # is missing,
(ii) main should be in the lower case, followed by semicolon.
(iii) float should be in lower case.
(iv) Output operator should be <<.
(v) In place of a>>b, it should be x and y and semicolon is also missing.
(vi) String should be enclosed in double quotes in place of single quotes and two numbers cannot be displayed as a,b, it should be << in place of comma(,).
9.
typedef keyword is used to assign alternative names to existing data types.
e.g. typedef int in;
Now, whenever we want to declare a variable of types integer, rather than using int, we can use 'in' keyword in place.
e.g. void main()
{
typedef int in;
//in is an alternetive name to int
in a=10;
cout<<a; // a is of type integer
10.
The output is 5, 3, 4, 4
11.
Type casting It is used by the programmer to convert value of one type to another type. It is forced type conversion. It is done by putting the target datatype in parentheses before the data to be converted.
e.g. float X=(double)15/6);
Automatic type conversion It is automatically done by the compiler itself wherever required. It is implicit type conversion
e.g. float X=3;
12.
An unsigned int can represent 0 to 65536 value in total, whereas a signed int can represent -32768 to 32767, i.e. 65536 values. The total numbers represented by both integers are the same but the range represented by unsigned int becomes double because in place of negative numbers positive values are represented thereby increasing the range by 32768 numbers as there are many negative values represented by signed int.
13.
1*1=1
1*3=3
1*5=5
2*1=2
2*3=6
2*5=10
a=32
Now k=2, b=2, c=2.666667
14.
#include
#include
void main()
{
int n, i;
clrscr();
cout<<"Enter the number to find the multiple";
cin>>n;
for(i=1;i<=10;i++)
cout< getch();
}
15.
( )
#include<iostream.h> ---> cout
#include<string.h> -----> strlen()
16.
( )
In switch -case statement, when a match is found, the statement sequence associated with that case is executed until a break statement or the end of switch statement is reached. So, if break statement is missing, then the statement sequence is executed until the end of the switch-case statement is reached.
17.
( )
In an entry controlled loop, the condition is evaluated at the entry point of the loop, e.g. for and while loop. while is an exit controlled loop, the condition is evaluated at the exit point of the loop, e.g. do-while loop.
18.
( )
Value of x will be 10 because local variable hides global variable.
19.
( )
( x == y ) || ( ! ( z == y ) ) && ( z < x )
= (10 == 5) || (! (11 == 5) )&&( ( 11< 10)
= (10 == 5)||(1 && (11 < 10))
= (10 == 5)||(1 && 0)
= 0 || 0
= 0
20.
( )
Yes, it is correct statement because a char can hold characters with equivalent ASCII values in the range 0-255.
21.
( )
= is a assignment operator, which assign a value while == is a relational operator, which test the equality.
22.
( )
'I' operator used to find the quotient, whereas '%' operator used to find the remainder.
23.
( )
The output is as
45 45
45
46
24.
( )
The four data types are : char,short, int and long.
12th Standard CBSE Syllabus & Materials
12th Standard CBSE
CBSE 12th Computer Science Python Revision Tour I - New Previous year Question Papers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Business Studies Planning Important Questions And Answers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Business Studies Business Environment Important Questions And Answers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Business Studies Principles of Management Important Questions And Answers Study Material - QB365 Set A
CBSE 12th Standard CBSE Subjects
CBSE Standards