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: 20/08/2019
Review of C++
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>
void main()
{
struct STUDENT
{
char stu_name[20];
char stu_sex;
int stu_age=17;
}student;
gets(stu_name);
gets(stu_sex);
}
2.
What is the benefit of using default parameter/ argument in a function? Give a suitable example to illustrate it using C++ code.
3.
What is the function of typedef in C++ Also, give a suitable C++ code to illustrate it?
4.
Write the output of the following program.
Void main()
{
int x=5, y=5;
cout<<x--;
cout<<",";
cout<<--x;
cout<<",";
cout<<y--<<","<<--y;
}
5.
An unsigned int can be twice as large as the signed int. Explain how?
6.
To illustrate the concept of passing entire structure as function argument using pass by reference.
7.
Write the following program execute successfully? If not, state the reason(s).
#include<stdio.h>
void main()
{
int x, sum=0;
cin<<n;
for( X=1, x<100, x+=2)
if x%2==0
sum +=x;
cout>>"sum=">>sum;
}
8.
To show the working of exit statement.
9.
To show the use of goto statement.
10.
To print the numbers 0 to 10 with the help of for loop.
11.
To know the use of if-else statement.
12.
To show the use of if statement.
13.
To show how the statements are being executed sequentially with the help of addition of two integers.
14.
Declare a structure applicant to store the following data: Applicant name, Code number, Data of birth (day,month,year)
15.
In the following program:
i) How many times will the while loop run?
ii) What would be the last value of A displaced out?
#include<iostream.h>
void main()
{
int A=10;
while(++A<15)
{
cout<<A++;
}
}
16.
Which value of x will be printed in following case and why?
int x=9;
void main()
{
int x = 10;
cout<<x;
}
17.
Do you see any similarity between a typedef name and a reference name? If yes, what is it?
18.
If v is an identifier of int type and is holding value 255. Is the following statement correct?
char code = v;
19.
Generally there are four data types, each of which can be signed or unsigned.Write names of all four data types.
20.
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();
}
1.
#include<iostream.h>
#include<stdio.h>
void main()
{
struct STUDENT
{
char stu_name[20];
char stu_sex;
int stu_age;
}student;
gets(student.stu_name);
cin>>(student.stu_sex);
}
2.
A default parameter is a function parameter that has a default value provided to it. If the user does not supply a value for this parameter, the default value will be used.
If the user does supply a value for the default parameter, the user supplied value is used.
Consider the following program:
void Printvalues(int nValue1, int nValue2=10)
{
cout<<"1st value:"<<nValue1<<endl;
cout<<"2nd value:"<<nValue2<<endl;
}
int main()
{
PrintValue(1);
//nValues2 will use default parameter
//of 10
PrintValues(3,4);
//override default value for nValue2
return 0;
}
Output
1st value:1
2nd value:10
1st value:3
2nd value:4
3.
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 alternative name to int
in a=10;
cout<<a: //a is of type integer
}
4.
The output is 5, 3, 4, 4
5.
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.
6.
#include<iostream.h>
#include<conio.h>
struct students_record
{
int s_rollno,s_class;
};
void display(struct students_record*s1);
void main()
{
struct students_record s1;
s1.s_rollno=14;
s1.s_class=2;
display(&s1);
getch();
}
void display(struct students_record *s1)
{
cout<<"\nRoll no: "<<s1->s_rollno;
cout<<"\nClass: "<<s1->s_class;
}
Output
Roll no:14
Class:2
7.
The given program does not execute successfully because following errors are occurred during the execution:
#include<iostream.h>
//required for cin and cout
#include<stdio.h>
voidmain()
{
int x, sum=0,n;
//n should be declared before use
cin>>n;
/*Here should be input operator >> in place of output operator<<*/
for( X=1;X<100; X+=2)
/*Here should be(;) in place of(,) and x in place of x. */
if (X%2==0)
sum+=X;
/* if expression should closed in brackets() and here, should be X in place of x*/
cout<<"sum="<<sum;
/*Here should be output operator << in place of input operator >
}
8.
#include<iostream.h>
#include<conio.h>
#include<process.h>
void main()
{
int j;
cout<<"Enter the bit value 0, 1 "<<"\n";
cin>>j;
switch(j)
{
case 0;
cout<<"Bit value is 0"<<"\n";
case 1;
cout<<"Bit value is 1"<<"\n";
break;
default:
exit(0);
}
getch();
}
Output
Enter the bit value 0,1
0
Bit value is 0
9.
#include<iostream.h>
#include<conio.h>
void main()
{
int i, j;
for(i=0; i<10; i++)
{
cout<<"\n Outer loop executing. i="<<i;
for(j=0; j<2; j++)
{
cout<<"\n Inner loop executing. j="<<j;
if(i==3)
goto stop;
}
}
cout<<"\n Loop exited. i="<<i;
stop;
//This message does not print
cout<<"\n Jumped to stop. i="<<i;
getch();
}
Output
Outer loop executing. i=0
Inner loop executing. j=0
Inner loop executing. j=1
Outer loop executing. i=1
Inner loop executing. j=0
Inner loop executing. j=1
Outer loop executing. i=2
Inner loop executing. j=0
Inner loop executing. j=1
Outer loop executing. i=3
Inner loop executing. j=0
Jumped to stop. i=3
10.
#include
#include
void main()
{
int count;
for(count=0; count<11; count++)
cout<
getch();
}
Output
0 1 2 3 4 5 6 7 8 9 10
It is divided into three parts
| Expression | Name | Purpose |
|---|---|---|
| count=0 | Initialise expression | Initialises loop variable |
| count<11 | Test expression | Test loop variable |
| count++ | Increment expression | increment loop variable |
11.
#include<iostream.h>
void main()
{
int code;
code =1;
if( code==1)
cout<<" The water was too warm\n"
else
cout<<" the water were all finished";
}
Output:
The water was too warm
Some of valid if-else statements are:
(i) If ((ch >= 'a') && (ch <= 'z'))
cout<<ch<<" is a lowercase letter";
cout<<ch<<" is not a lowercase letters";
(ii) if((age == 50) || (age >= 20))
cout<<" You are old";
else
cout<<" You are young";
12.
#include<iostream.h>
void main()
{
int a, b;
a=10; b=20;
if(a<b)
cout<<"a is less than b";
}
Output
a is less than b
13.
#include<iostream.h>
void main()
{
int x, y, sum;
cout<<" A program which adds two integers\n";
cout<<"Enter 1st integer:";
cin>>x;
cout<<"Enter 2st integer:";
cin>>y;
sum = x+y;
cout<<"sum is "<<sum
}
Output
A program which adds two integers
Enter the 1st integer: 20
Enter the 2nd integer: 25
Sum is 45
14.
( )
struct dob
{
int day;
int month;
int year;
};
struct applicant
{
char name[30];
int code;
dob date;
};
15.
( )
i) 2 times the while loop will run.
ii) The last value of A displaced out is 13.
16.
( )
Value of x will be 10 because local variable hides global variable.
17.
( )
Yes, there is a similarity between a typedef name and a reference name. A typedef name is an alias name of an already defined data type and a reference name is an alias name of an already defined variable.
18.
( )
Yes, it is correct statement because a char can hold characters with equivalent ASCII values in the range 0-255.
19.
( )
The four data types are : char,short, int and long.
20.
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
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