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: 15/02/2019
Review Of C++ Important Questions
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.
Find the output of the following program:
#include<iostream.h>
#include<ctype.h>
void changeIt(char Text[],char C)
{
for(int K=0;Text[K]!='\0';K++)
{
if(Text[K]>='F'&&Text[K]<='L')
Text[K]=tolower(Text[k]);
else
if(Text[K]=='E'||Text[K]=='e');
Text[K]=C;
else
if(K%2==0)
Text[K]=toupper(Text[K]);
else
Text[K]=Text[K-1];
}
}
void main()
{
char OldText[]="pOwERALone";
changeIt(OldText,'%');
cout<<"New Text:"<<OldText<<endl;
}
2.
user question
3.
c^^
4.
Find the output the following program:
#include<iostream.h>
void main()
{
int First=25, sec=30;
for( int I=1; I<=2;I++)
{
cout<<"Output 1="<
cout<<"Output 2="<<--Sec<<" & "<
}
}
5.
Differentiate between the post-increment and pre-increment operators. Also, give a suitable C++ code to illustrate both.
6.
Differentiate between logical error and syntax error. Also, give suitable examples of each in C++.
7.
What is the difference between #define and const? Explain with suitable example.
8.
Find the output of the following program.
#include<iostream>
void main()
{
int x=5, y;
y=x++ + ++x;
cout<<++y<<" "<<y++;
}
9.
What is the difference between automatic conversion and type casting? Also, give a suitable C++ code to illustrate both
10.
Give the difference between the type casting and automatic type conversion. Also, give a suitable C++ code to illustrate both.
11.
test quewtsion s testkavin
12.
To pass the structure elements to function.
13.
Write definition for a function sumseries() in C++ with two arguments/parameters-double x and int n. The function should return a value of type double and it should perform sum of the following series:
x-x2/3!+x3/5!-x4/7!+x5 /9!.... upto n terms.
14.
To input 3 subject marks for 3 students and print the marks using two-dimensional array.
15.
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;
}
16.
Rewrite the following program after removing the syntactical error(s), (if any). Underline each correction.
#include<iostream.h>
const int Multiple 3;
void main()
{
value = 15;
for( int Counter=1; Counter=<5; Counter++, value-=2)
if(value%Multiple==0)
cout<<Value*Multiple;
cout<<endl;
else
cout<<Value+Multiple<<endl;
}
17.
To print the numbers using break statement.
18.
To print the numbers from 1 to 10 with the help of while loop
19.
To check the number is divisible by 6 or not using nested if statement
20.
To show how the statements are being executed sequentially with the help of addition of two integers.
21.
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();
}
22.
Write a C++ program to generate and display all the armstrong numbers between 1 and 200.
23.
Write a program to print the following output after inputting the value of n. The user should be prompted again for the value of n, if the inputted value does not lie between 1 to 6 do the inclusive.
1
1 2 3
1 2 3 4 5
1 2 3 4 5 6 7
- - - - - - -
1 2 - - - - - - (2n-1)
24.
Write a program in C++ to print first 10 multiples of an integer N, where N is to be entered by user:
25.
Declare a structure applicant to store the following data: Applicant name, Code number, Data of birth (day,month,year)
26.
A function printing is defined as
void printing(char c= '*', int l=40)
{
for(int x=0;x<1;x++)
cout<<c;
cout<<endl;
}
How will you invoke the function printing for following output:
i) to print '*' 40 times
ii) to print '=' 30 times
27.
Write the names of the header files to which the following belong: i) puts() ii) sin()
28.
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;
}
29.
Observe the following C++ code and write the name(s) of the header file(s),which will be essentially required to run it in a C++ compiler.
void main()
{
int Number;
cin>>Number;
if(abs(Number)==Number);
cout<<"Positive"<<endl;
}
30.
What will be the output of the following program?
#include<iostream.h>
void main()
{
int ind;
for(ind=0; ind<=10; ind++)
cout<<" "<<ind;
}
31.
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++;
}
}
32.
Which value of x will be printed in following case and why?
int x=9;
void main()
{
int x = 10;
cout<<x;
}
33.
How 'I' operator is different from '%' operator?
34.
Generally there are four data types, each of which can be signed or unsigned.Write names of all four data types.
1.
NEW Text:PPW%RRIIN%
2.
gdfgdsgdfg
3.
C^^
4.
Output 1=25&35
Output 2=29&21
Output 1=26&34
Output 2=28&22
5.
When ++ operator is used after an operand to increment its value by 1. Its called a post-increment operator. By post-increment operator, the value of the operand is first used in the expression and then the operand's value is incremented by 1.
When ++ operator is used before an operand to increment its value by 1. Its called a pre-increment operator. By pre-increment operator, the value of the operand is first increment by 1 and then the operand's value is used in the expression.
e.g.
int a=5, b=5, c=0, d=0;
c = c+ ++a;
d = d+ b++;
cout<<c<<a<<endl;
cout<<d<<b;
The output is:
66
56
6.
Logical error Wrong logic in the program cause a program to produce undesired output or no output. Such kind of errors are called logical errors. These errors depend on the logical explanation and are easy to detect, if we follow the line of execution and determine why the program takes that path of execution.
e.g. if in place of
\(a+\frac { b }{ 2 } \), by mistake, \(a*\frac { b }{ 2 } \) is written, it will be a logical error.
Syntax error A syntax error is the error that occurs when rules of C++ language are violated in the program
e.g. in statement
cout<<"hello",
\(\therefore \) statement(;) missing is a syntax error.
7.
#define preprocessor directive is used to define a macro with some value/expression, which is substituted during compilation of program. Unlike variable, it does not occupy memory. e.g.
#define Max 10
void main()
{
int arr[Max];
}
Const It is used in declaration of variable, it occupies memory to store a constant value, which once initialised cannot be changed
e.g. const int x=10;
8.
The output is
14 12
9.
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;
10.
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;
11.
12.
#include<iostream.h>
#include<conio.h>
struct students_record
{
int s_rollno, s_class;
};
void display(int, int);
void main()
{
students_record s1={24,11};
display(s1.s_rollno,s1.s_class);
getch();
}
void display(int rollno, int Class)
{
cout<<"\nRoll no: "<<rollno;
cout<<"\nClass: "<<Class;
}
Output
Roll no:24
Class:11
13.
#include<iostream.h>
#include<conio.h>
double sumseries(double x, int n)
{
double series=0, pow, fact, term;
int i,j,k;
for(i=1,k=1;i<n;i++,k+=2)
{
for(pow=1,j=1;j<1;j++)
pow*=x;
for(fact=1,j=1;j<=k;j++)
fact*=j;
term=pow/fact;
if(i%2==0)
series_=term;
else
series+=term;
}
return series;
}
14.
#include<iostream.h>
#include<conio.h>
void main()
{
int marks[3][3],i,j;
cout<<"Marks table for 3 students"<<endl;
for(i=0;i<3;i++)
{
cout<<"Enter 3 subject marks for student"<<i+1<<":";
for(j=0;j<3;j++)
{
cin>>marks[i][j];
}
}
cout<<"Table for student's marks";
cout<<endl;
for(i=0;i<3;i++)
{
cout<<i+1<<":"<<" ";
for(j=0;j<3;j++)
{
cout<<" "<<marks[i][j];
}
cout<<endl;
}
getch();
}
Output
Marks table for 3 students
Enter 3 subject marks for student1:80 70 75
Enter 3 subject marks for student2:90 78 59
Enter 3 subject marks for student3:79 89 84
Table for student's marks
1: 80 70 75
2: 90 78 59
3: 79 89 84
15.
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 >
}
16.
#include<iostream.h>
const int Multiple =3; //Correction 1
void main()
{
int value = 15; //Correction 2
for( int Counter=1; Counter<=5; Counter++, value-=2) //Correction 3
if(value%Multiple==0)
{
cout<<Value*Multiple;
cout<<endl;
} //correction 4 else
cout<<Value+Multiple<<endl;
}
Correction 1 Multiple must be assigned a value.
Correction 2 Variable value must be declared with datatype.
Correction 3 =< Must be replace with <=.
Correction 4 Misplace else; so after if, compound statement must be enclosed with { }.
17.
#include<iostream.h>
#include<conio.h>
void main()
{
int i;
for(i=1; i<10; i++)
{
cout<<i<<" ";
if(i==4)
break;
}
getch();
} //Loop exit after printing 1 through 4
Output
1 2 3 4
18.
#include<iostream.h>
#include<conio.h>
void main()
{
int count;
count = 1;
while(count<10)
{
cout<<count<<" ";
}
getch();
}
Output
1 2 3 4 5 6 7 8 9 10
19.
#include<iostream.h>
#include<conio.h>
void main()
{
int num;
clrscr();
cout<<" enter the number";
cin>>num;
if(num%2==0)
{
if(num%3==0)
cout<<"Number is divisible by 6';
else
cout<<"Number is not divisible by 6';
}
else
cout<<" The number is not divisible by 2 so, it is not divisible by 6";
getch();
}
Output
Enter the number 30
Number is divisible by 6
20.
#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
21.
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
22.
#include<iostream.h>
#include<conio.h>
void main()
{
int i,j,k,l;
clrscr();
cout<<"The armstrong numbers in between 1 and 200 are";
for(i=1;i<=200;i++)
{
k=0,j=i;
while(j!=0)
{
l=j;
k=k+1*1*1;
j=j/10;
}
if(k==i)
cout<<"\n"<<i;
}
getch();
}
23.
#include<iostream.h>
#include<conio.h>
void main()
{
int a;
do
{
cout<<"Enter a";
cin>>a;
}
while((a<1)||(a<6));
for(int i=0;i<=a;i++)
{
for(int k=1;k<=(a-i);k++)
cout<<" "<<" ";
for(int j=1;j<=(2*i-1);j++)
cout<<j<<" "<<" ";
cout<<"\n";
}
getch();
}
24.
#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();
}
25.
( )
struct dob
{
int day;
int month;
int year;
};
struct applicant
{
char name[30];
int code;
dob date;
};
26.
( )
i) printing();
ii) printing('=', 30);
27.
( )
i) puts() belongs to #include<stdio.h>
ii) sin() belongs to #include<math.h>
28.
( )
#include<iostream.h> ---> cout
#include<string.h> -----> strlen()
29.
( )
iostream.h ----> cin,cout
math.h -------> abs()
30.
( )
The output is
0 1 2 3 4 5 6 7 8 9 10
31.
( )
i) 2 times the while loop will run.
ii) The last value of A displaced out is 13.
32.
( )
Value of x will be 10 because local variable hides global variable.
33.
( )
'I' operator used to find the quotient, whereas '%' operator used to find the remainder.
34.
( )
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