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: 23/09/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.
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;
}
2.
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;
}
3.
To show the use of continue statement.
4.
To check the number is divisible by 6 or not using nested if statement
5.
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();
}
6.
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)
1.
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 >
}
2.
#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 { }.
3.
#include<iostream.h>
#include<conio.h>
void main()
{
int i=0;
do
{
i++;
cout<<"before the continue\n";
continue;
cout<<"after the continue, should";
cout<<"never print\n";
} while(i<3)
cout<<"after the do loop\n";
getch();
}
Output
before the continue
before the continue
before the continue
after the do loop
4.
#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
5.
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
6.
#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();
}
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