Sie sind auf Seite 1von 13

CBSE Question OUTPUT Marks:2+3+2

 CBSE 2014
1. (a) Obtain the output from the following C++ program as expected to appear on the
screen after its execution
Important Note:
- All the desired header files are already included in the code, which are required to
run the code.
void main()
{
char *String=”SARGAM”;
int *Ptr, A[] = {1, 5, 7, 9};
Ptr = A;
cout<<*Ptr<<String<<endl;
String++;
Ptr+=3;
cout<<*Ptr<<String<<endl;
}
(b) Obtain the output of the following C++ program, which will appear on the screen
after its execution.
Important Note:
- All the desired header files are already included in the code, which are required to
run the code.
class Player
{
int Score, Level;
char Game;
public:
Player(char GGame = ‘A’)
{
Score = 0;
Level = 1;
Game = GGame;
}
void Start(int SC);
void Next();
void Disp()
{
cout<<Game<<”@”<<Level<<endl;
cout<<Score<<endl;
}
};
void main()
{
Player P, Q ( ‘B’ );
P.Disp();
Q.Start(75);
Q.Next();

By Sunil Kumar Mobile No.: 9868583636 Page 1 of 13


CBSE Question OUTPUT Marks:2+3+2

P.Start(120);
Q.Disp();
P.Disp();
}
void Player :: Next()
{
Game = (Game == ‘A’) ? ‘B’ : ‘A’;
}
void Player :: Start(int SC)
{
Score += SC;
If(Score>=100)
Level = 3;
else if(Score>=50)
Level = 2;
else
Level = 1;
}
(b) Read the following C++ code carefully and find out, which out of the given options (i) to
(iv) are expected correct output(s) of it. Also, write the maximum and minimum value that
can be assigned to the variable Start used in the code:
void main()
{
int Guess[4] = {200, 150, 20, 250};
int Start = random(2) + 2;
for(int C=Start; C<4; C++)
cout<<Guess[C]<<”#”;
}
(i) 200# 150# (iii) 150#20#250#
(ii) 150#20# (iv) 20#250#

 CBSE 2013
2. (a) Observe the following C++ code carefully and obtain the output, which will appear on
the screen after execution of it.
Important Note:
- All the desired header files are already included in the code, which are required to
run the code.
void main()
{
char *String = “SHAKTI”;
int *Point, Value[ ] = { 10, 15, 70, 19};
Point = Value;
cout<<*Point<<String<<endl;
String++;
Point++;
cout<<*Point<<String<<endl;

By Sunil Kumar Mobile No.: 9868583636 Page 2 of 13


CBSE Question OUTPUT Marks:2+3+2

}
(b) Observe the following C++ code carefully and obtain the output, which will appear on
the screen after execution of it.
#include<iostream.h>
class Aroundus
{
int Place, Humidity, Temp;
public:
Aroundus(int P=2)
{
Place = P;
Humidity = 60;
Temp = 20;
}
void Hot(int T)
{
Temp += T;
}
void Humid(int H)
{
Humidity += H;
}
void JustSee()
{
cout<<Place<<”:”<<Temp<<”&”<<Humidity<<”%”<<endl;
}
};
void main()
{
Aroundus A, B(5);
A.Hot(10);
A.JustSee();
B.Humid(15);
B.Hot(2);
B.JustSee();
A.Humid(5);
A.JustSee();
}
(c) Based on the following C++ code, find out the expected correct output(s) from the
options (i) to (iv). Also, find out the minimum and the maximum value that can be
assigned to the variable Trick used in the code at the time when value of Count is 3:
void main()
{
char Status[][10] = { “EXCEL”, “GOOD”, “OK”};
int Turn=10, Trick;
for (int Count=1; Count<4; Count++)

By Sunil Kumar Mobile No.: 9868583636 Page 3 of 13


CBSE Question OUTPUT Marks:2+3+2

{
Trick = random(Count);
cout<<Turn-Trick<<Status[Trick]<<”#”;
}
}
(i) 10EXCEL#10EXCEL#8OK#
(ii) 10EXCEL#8OK#9GOOD#
(iii) 10EXCEL#9GOOD#10EXCEL#
(iv) 10EXCEL#10GOOD#8OK#
 CBSE 2012
3. (a) Find the output of the following program:
#include <iostream.h>
class TRAIN
{
int Tno, TripNo, PersonCount;
public:
TRAIN(int Tmno=1)
{
Tno = Tmno;
TripNo = 0;
PersonCount=0;
}
void Trip(int TC=100)
{
TripNo++;
PersonCount+=TC;
}
void Show()
{
cout<<Tno<<”:”<<TripNo<<”:”<<PersonCount<<endl;
}
};
void main()
{
TRAIN T(10), N;
N.Trip();
T.Show();
T.Trip(70);
N.Trip(40);
N.Show();
T.Show();
}
(b) Find the output of the following program:
#include <iostream.h>
#include <ctype.h>
typedef char Txt80 [80];

By Sunil Kumar Mobile No.: 9868583636 Page 4 of 13


CBSE Question OUTPUT Marks:2+3+2

void main()
{
char *PText;
Txt80 Txt = “Ur2GReAt”;
int N = 6;
PText = Txt;
while (N>=3)
{
Txt[N] = (isupper(Txt[N]) ? tolower(Txt[N]) : toupper(Txt[N]));
cout<<PText<<endl;
N--;
PText++;
}
}
(c) Observe the following program and find out, which output(s) out of (i) to (iv) will not
be expected from the program? What will be the minimum and the maximum value
assigned to the variable Chance?
#include <iostream.h>
#include <stdlib.h>
void main()
{
randomize();
int Game[ ] = {10,16}, P;
int Chance = random(2) + 5;
for(int T=0; T<2; T++)
{
P = random(2);
cout<<Game[P]+Chance<<”#”;
}
}
(i) 15#15#
(ii) 22#16#
(iii) 16#22#
(iv) 16#21#
 CBSE 2011
4.
(a) Find the output of the following program:
#include<iostream.h>
void SwitchOver ( int A[ ], int N, int Split )
{
for ( int K=0; K<N; K++ )
if( K < Split )
A[K] += K;
else
A[K] *= K;
}

By Sunil Kumar Mobile No.: 9868583636 Page 5 of 13


CBSE Question OUTPUT Marks:2+3+2

void Display ( int A[ ], int N )


{
for( int K=0; K<N; K++ )
(K%2 != 0)? cout<<A[K]<<"%" : cout<<A[K]<<endl;
}
void main( )
{
int H [ ] = {30, 40, 50, 20, 10, 5 };
SwitchOver ( H, 6, 3 );
Display ( H, 6 );
}
(b) Find the output of the following program :
#include <iostream.h>
void main()
{
int *Queen, Moves [ ] = {11, 22, 33, 44 };
Queen = Moves;
Moves[2] += 22;
cout<<”Queen @”<<*Queen<<endl;
*Queen -= 11;
Queen += 2;
cout<<”Now @”<<*Queen<<endl;
Queen++;
cout<<”Finally @”<<*Queen<<endl;
cout<<”New Origin @”<<Moves[0]<<endl;
}
(c) Go through the C++ code shown below, and find out the possible output
or outputs from the suggested Output Options (i) to (iv). Also, write the
minimum and maximum values, which can be assigned to the variable
MyNum. 2
#include <iostream.h>
#include <stdlib.h>
void main()
{
randomize();
int MyNum, Max = 5;
MyNum = 20 + random(Max);
for ( int N=MyNum; N<=25; N++)
cout<<N<<”*”;
}
(i) 20*21*22*23*24*25

By Sunil Kumar Mobile No.: 9868583636 Page 6 of 13


CBSE Question OUTPUT Marks:2+3+2

(ii) 22*23*24*25*
(iii) 23*24*
(iv) 21*22*23*24*25*

 CBSE 2010
5. (a) Find the output of the following program:
#include <iostream.h>
struct THREE_D
{ int X, Y, Z; };
void MoveIn(THREE_D &T, int Step = 1)
{
T.X += Step;
T.Y -= Step;
T.Z += Step;
}
void MoveOut ( THREE_D &T, int Step = 1)
{
T.X -= Step;
T.Y += Step;
T.Z -= Step;
}
void main()
{
THREE_D T1 = {10, 20, 5}, T2 = {30, 10, 40};
MoveIn ( T1 );
MoveOut ( T2, 5 );
cout<<T1.X<<”,”<<T1.Y<<”,”<<T1.Z<<endl;
cout<<T2.X<<”,”<<T2.Y<<”,”<<T2.Z<<endl;
MoveOut ( T2, 10);
cout<<T2.X<<”,”<<T2.Y<<”,”<<T2.Z<<endl;
}
(b) Find the output of the following program:

 CBSE 2009
(a) Find the output of the following program:
#include <iostream.h>

By Sunil Kumar Mobile No.: 9868583636 Page 7 of 13


CBSE Question OUTPUT Marks:2+3+2

void main()
{
int X [ ] = {10, 25, 30, 55, 110 };
int *p = X;
while ( *p < 110 )
{
if( *p % 3 != 0 )
*p = *p + 1;
else
*p = *p + 2;
p++;
}
for( int I=4; I>=1; I--)
{
cout<<X[I]<<”*”;
if( I%3==0)
cout<<endl;
}
cout<<X[0] *3<<endl;
}
(b) Find the output of the following program:
#include <iostream.h>
#include <ctype.h>
void Encode ( char Info[ ], int N);
void main()
{
char Memo [ ]= “Justnow”;
Encode(Memo, 2);
cout<<Memo<<endl;
}
void Encode ( char Info[ ], int N)
{
for ( int I=0; Info[I] != ‘\0’; I++)
if ( I%2 == 0)
Info[I] = Info[I] – N;
else if ( islower(Info[I]))
Info[I] = toupper(Info[I]);
else
Info[I] = Info[I] + N;
}

By Sunil Kumar Mobile No.: 9868583636 Page 8 of 13


CBSE Question OUTPUT Marks:2+3+2

c) Study the following program and select the possible output from it:
#include <iostream.h>
#include <stdlib.h>
const int LIMIT = 4;
void main()
{
randomize();
int Points;
Points = 100 + random ( LIMIT );
for ( int P=Points; P>=100; P--)
cout<<P<<”#”;
cout<<endl;
}
(i) 103#102#101#100#
(ii) 100#101#102#103#
(iii) 100#101#102#103#104#
(iv) 104#103#102#101#100#
 CBSE 2008
a) Find the output of the following program:
#include <iostream.h>
#include <conio.h>
void main()
{
char Text[ ] = “Mind@Work!”;
for( int I=0; Text[I] != ‘\0’; I++)
{
if(!isalpha(Text[I]))
Text[I] = ‘*’;
else if(isupper(Text[I]))
Text[I] = Text[I] + 1;
else
Text[I] = Text[I + 1];
}
cout<<Text;
}

By Sunil Kumar Mobile No.: 9868583636 Page 9 of 13


CBSE Question OUTPUT Marks:2+3+2

b) Find the output of the following program:


#include <iostream.h>
void main()
{
int U = 10, V = 20;
for( int I=1; I<=2; I++)
{
cout<<”[1]=”<<U++<<”&”<<V-5<<endl;
cout<<”[2]=”<<++V<<”&”<<U+2<<endl;
}
}
c) In the following program, find the correct possible output(s) from the
options:
#include <stdlib.h>
#include <iostream.h>
void main()
{
randomize();
char City[][10] = { “DEL”, ”CHN”, ”KOL”, ”BOM”, ”BNG” };
int Fly;
for( int I=0; I<3; I++)
{
Fly=random(2) + 1;
cout<<City[Fly]<<”:”;
}
}
Outputs:
(i) DEL:CHN:KOL:
(ii) CHN:KOL:CHN:
(iii) KOL:BOM:BNG:
(iv) KOL:CHN:KOL:

By Sunil Kumar Mobile No.: 9868583636 Page 10 of 13


CBSE Question OUTPUT Marks:2+3+2

 CBSE 2007
8.
a) Find the output of the following program:
#include <iostream.h>
void main()
{
int Array[ ] = { 4, 6 10, 12 };
int *pointer = Array;
for ( int I=1’ i<=3; i++)
{
cout<<*pointer<<”#”;
pointer++;
}
cout<<endl;
for (I=1; I<=4; I++)
{
(*pointer) *= 3;
--pointer;
}
for (I=1; I<5; I++)
cout<<Array[I-1]<<”@”;
cout<<endl;
}
b) Find the output of the following program:
#include <iostream.h>
void Withdef ( int HisNum = 30)
{
for (int I=20; I<=HisNum; I+=5)
cout<<I<<” “;
cout<<endl;
}
void Control (int & MyNum)
{
MyNum+=10;
Withdef(MyNum);
}
void main()
{
int YourNum = 20;
Control(YourNum);
Withdef();
cout<<”Number=”<<YourNum<<endl;
}

By Sunil Kumar Mobile No.: 9868583636 Page 11 of 13


CBSE Question OUTPUT Marks:2+3+2

c) In the following C++ program what is the expected value of MyMarks from Option (i) to
(iv) given below. Justify answer.
#include <stdlib.h>
#include <iostream.h>
void main()
{
randomize();
int Marks [ ] = {99, 92, 94, 96, 93, 95 }, MyMarks;
MyMarks = Marks [ 1 + random(2) ];
}
(i) 99 (ii) 94 (iii) 96 (iv) None of the above

 CBSE 2006
9.
(a) Find the output of the following program:
#include <iostream.h>
#include <string.h>
class state
{
char *state_name;
int size;
public:
state() { size=0; state_name = new char [ size+1]; }
state(char *s)
{
size = strlen(s);
state_name = new char [size+1];
}
void display()
{
cout<<state_name<<endl;
}
void Replace ( state & a, state & b)
{
size = a.size + b.size;
delete state_name;
state_name = new char [size + 1];
strcpy(state_name, a.state_name);
strcat(state_name, b.state_name);
}
};
void main()
{
char *temp = “Delhi”;

By Sunil Kumar Mobile No.: 9868583636 Page 12 of 13


CBSE Question OUTPUT Marks:2+3+2

state state1(temp), state2(“Mumbai”), state3(“Nagpur”), S1,S2;


S1.Replace(state1, state2);
S2.Replace(S1, state3);
S1.display();
S2.display();
}
b) Find the output of the following program:
#include <iostream.h>
void main()
{
long NUM = 1234543;
int F=0, S=0;
do
{
int Rem = NUM%10;
if(Rem%2 != 0)
F += Rem;
else
S += Rem;
NUM /= 10;
}while(NUM > 0);
cout<<F-S;
}

By Sunil Kumar Mobile No.: 9868583636 Page 13 of 13

Das könnte Ihnen auch gefallen