Qno 1 (e)

advertisement
XII CBSE Previous
Year Question
Paper
QUESTION NO
1 (E)
2 or 3 Marks
1 (e) Find the output of the following program :
Delhi 2006
2
#include<iostream.h>
void main( )
{ long NUM= 1234543;
int F=0, S=0;
do
{ int Rem = NUM% 10 ;
if (Rem % 2 !=0)
F+=R;
else
S+=R;
NUM /=10;
}while(NUM>0);
cout<<F-S;
}
Ans:
(e)
2 (assuming R as Rem)
(2 marks for correct output as 2)
OR
(2 marks for identifying error as R is not declared)
OR
(Full 2 marks to be awarded to the students who
have scored at least
1 mark in the entire Q. No. 1 i.e. from 1(a) to 1(f))
2 (e) Find the output of the following program :
OD 2006
2
#include<iostream.h>
void main()
{ long Number = 7583241;
int First=0, Second=0;
do
{ int R = Number%10;
if(R%2==0)
First+=R;
else
Second+=R;
Number /=10;
}while(Number>0);
cout<<First-Second;
}
(e) -2
(Full 2 marks for correct output)
OR
(Full 2 marks for mentioning values of First as 14
and Second as 16, as representation of minus
sign is not very prominent)
OR
(Full 2 marks for mentioning syntax error with
justification as insertion operator << expected in
between First and Second)
3 (e) Find the output of the following program :
Delhi 2007
#include<iostream.h>
void Indirect(int Temp=20)
{
for (int 1=10; I<=Temp; I+=5)
cout<<I<<” , “ ;
cout<<endl;
}
void Direct (int &Num)
{
Num+=10;
Indirect(Num);
}
3
3 (e) Find the output of the following program :
Delhi 2007
void main()
{
int Number=20;
Direct(Number) ;
Indirect();
cout<< “ Number=” <<Number<<endl ;
}
3
(e)
10, 15, 20, 25, 30,
10, 15, 20,
Number=30
(1 Mark for each correct line of output)
Note:
· ½ Mark to be deducted for missing Commas
(,) in each line of output
· ½ Mark to be deducted if endl is not
considered in the output
4 (e) Find the output of the following program :
OD 2007
3
# include < iostream.h>
void Withdef (int HisNum = 30)
{
for (int 1=20 ; I<*= HisNum; I+=5)
cout<<I<<””;
cout<<endl;
}
void Control (int &MyNum)
{
MyNum+=10;
Withdef(MyNum);
}
4 (e) Find the output of the following program :
OD 2007
3
void main ()
{
int YourNum=20;
Control (YourNum);
Withdef();
cout<<”Number=”<<YourNum<<endl;
}
(e)
20,25,30,
20,25,30,
Number=30
(1 Mark for each correct line of output)
Note:
· ½ Mark to be deducted for missing Commas
(,) in the output
· ½ Mark to be deducted if endl is not
considered in the output
5 (e) Find the output of the following program:
Delhi 2008
2
#include<iostream.h>
void main ( )
{
int U = 10, V = 20;
for (int I = 1; 1 < = 2; 1++)
{
cout<<“[1]=”<<U++<<“&”<<V–5<<endl;
cout<<“[2]=”<<++V<<“&”< <U+ 2< <endl;
}
}
Ans:
Nnd@*Xrk!*
(½ Mark for N in the 1st position)
(½ Mark for nd in the 2nd and 3rd
position)
(½ Mark for @ in the 4th position)
(½ Mark for * in the 5th position)
(½ Mark for Xrk!)
(½ Mark for * at the end)
OR
(Fu1l 3 Marks If error is mentioned in the
code for Text (I) after last else)
6 (e) Find the output of the following program :
OD 2008 2
#include<iostream.h>
void main ( )
{
int A=5, B=10;
for (int I = 1; I<=2; 1++)
{
cout<< “Linel=”<<A++<<“&”<<B–2<<endl;
cout<<“Line2=”<<++B<<“&”<<A+3<<endl;
}
}
Ans:
Line1=5&8
Line2=11&9
Line1=6&9
Line2=12&10
(½ Mark for each correct line of output)
Note: .
½ Mark to be deducted for missing Ampersand
(&) in each line of output
½ Mark to be deducted if endl is not
considered in the output
7 (e) Find the output of the following program :
Delhi 2009
2
#include<iostream.h>
#include<ctype.h>
void Encode (char Info [ ], int N) ;
void main ( )
{
char Memo [ ] = “Justnow” ;
Encode(Memo, 2) ;
cout<<Memo<<endl ;
}
7 (e) Find the output of the following program :
Delhi 2009
2
void Encode(char Info[ ], int N)
{
for (int I = 0 ; Info[I] != ‘\0’ ; 1++)
if (1%2= =0)
Info[I] = Info[I] –N ;
else if (islower(Info[I]))
Info[I] = toupper(Info[I]) ;
else
Info[I] = Info[I] +N ;
}
Ans
HuqTlOu
(½ Mark for writing H, U as the first two
characters)
(½ Mark for writing q, T as the next two
characters)
(½ Mark for writing 1, O as the next two
characters)
(½ Mark for writing u as the last character)
8 (e) Find the output of the following program:
OD 2009
2
#include <iostream.h>
#include <ctype.h>
void Secret (char Mig [ ], int N);
void main ( )
{
char SMS[ ] = “rEPorTmE” ;
Secret{SMS,2);
cout<<SMS<<end1;
}
8 (e) Find the output of the following program:
OD 2009
2
void Secret(char Msg[ ], int N)
{
for (int C=0; Msg[C] ! =’ \0' ;C++)
if (C%2==0)
Msg[C] = Msg[C]+N;
else if (isupper(Msg[C]))
Msg[C] = tolower(Msg[C]);
else
Msg[C] = Msg[C]-N;
}
Ans
teRmttoe
(½ Mark for writing t,e as the first two
characters)
(½ Mark for writing R,m as the next two
characters)
(½ Mark for writing t,t as the next two
characters)
(½ Mark for writing o,e as the next two
characters)
9 (e) Find the output of the following program :
Delhi 2010
2
#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;
9 (e) Find the output of the following program :
Delhi 2010
2
else
if (K%2==O)
Text[K]=toupper(Text[K]);
else
Text[K]=Text[K-l];
}
}
9 (e) Find the output of the following program :
Delhi 2010
2
void main ( )
{
char OldText[ ]=”pOwERALone”;
ChangeIt(OldText,’%’);
cout<<“New TEXT:”<<OldText<<endl;
}
Ans.
16, 24, 6
6, 34, 16
18, 22, 28
(1 Mark for each line with -correct values)
OR
(½ Mark for any two correct values in each line)
Note:
Deduct (½ Mark if any/all ‘,’ missing
Deduct (½ Mark if endl is not considered at the right
positions
10 (e) Find the output of the following program:
OD 2010
2
#include <iostream.h>
#include <ctype.h>
void MyCode (char Msg [], char CH)
{
for (int (Cnt=O;Msg[Cnt]!=’\0';Cnt++)
{
if (Msg[Cnt]>=’B’ && Msg[Cnt]<=’G’)
Msg[Cnt]=tolower(Msg[Cnt]);
else
if (Msg[Cnt]==’A’|| Msg[Cnt]==’a’)
Msg[Cnt]=CH;
10 (e) Find the output of the following program:
OD 2010
2
else
if (Cnt%2==0)
Msg[Cnt]=toupper(Msg[Cnt]);
else
Msg[Cnt]=Msg[Cnt-l];
}
}
void main ()
{
char MyText [] =” ApEACeDriVE”;
MyCode(MyText,’@’);
cout<<“NEW TEXT:”<<MyText<<endl;
}
Ans.
NEW TEXT :@@e@ccddIIe
(½ Mark for writing @,@,e as the first three
characters)
(½ Mark for writing @,c,c as the next three
characters)
(½ Mark for writing d,d, I as the next three
characters)
(½ Mark for writing I,e as the next two characters)
Note:
Deduct ½ Mark for not mentioning NEW TEXT:
11 (e) Find the output of the following program:
Delhi 2011
2
#include<iostream.h>
void main ( )
{
int Track [ ] = {10, 20, 30, 40}, *Striker ;
Stxiker=Track :
Track [1] += 30 ;
cout<<"Striker>"<<*Striker<<end1 ;
Striker – =10 ;
Striker++ ;
cout<<"Next@"<<*Striker<<end1 ;
Striker+=2 ;
cout<<"Last@"<<*Striker<<end1 ;
cout<< "Reset To" <<Track[0] <<end1 ;
}
Ans
Striker>10
Next@50
Last@40
Reset to 0
(½ for writing each line of output correctly)
Note:
Deduct ½ Mark if any/all special characters are
missing
Deduct ½ Mark if endl is not considered at the
right positions
12 (e) Find the output of the following program:
OD 2011
#include<iostream.h>
void main ( )
{
int *Queen, Moves [ ] = {11, 22, 33, 44};
Queen = Moves;
Moves [2] + = 22;
cout<< "Queen @"<<*Queen<<end1;
*Queen - = 11;
Queen + = 2;
cout<< "Now @"<<*Queen<<end1;
Queen++;
cout<< "Finally@"<<*Queen«end1;
cout<< "New Origin @"<<Moves[0]<<end1;
}
2
Ans
Queen @11
Now @55
Finally @44
New origin @0
(½ Mark for writing each line of output
correctly)
Note:
Deduct ½ Mark if any/all '@' missing or/and
endl is not considered at the right positions
13 (e) Find the output of the following
program:
SAMPLE PAPER 2009 SET I
2
#include <iostream.h>
#include <ctype.h>
void Encrypt(char T[])
{
for (int i=0;T[i]!='\0';i+=2)
if (T[i]=='A' || T[i]=='E') T[i]='#';
else if (islower(T[i])) T[i]=toupper(T[i]);
else T[i]='@';
}
13 (e) Find the output of the following
program:
SAMPLE PAPER 2009 SET I
2
void main()
{
char Text[]="SaVE EArtH";//The
two words in the string Text
//are separated by single space
Encrypt(Text);
cout<<Text<<endl;
}
Answer:
@a@E@E#rTH
(1 Mark for writing all alphabets at correct
positions)
(1/2 Mark for writing @ at correct positions)
(1/2 Mark for writing # at correct position)
14 (e) Find the output of the following
program:
SAMPLE PAPER 2009 SET II
#include <iostream.h>
struct Game
{
char Magic[20];int Score;
};
void main()
{
Game M={“Tiger”,500};
char *Choice;
2
14 (e) Find the output of the following
program:
SAMPLE PAPER 2009 SET II
2
Choice=M.Magic;
Choice[4]=’P’;
Choice[2]=’L’;
M.Score+=50;
cout<<M.Magic<<M.Score<<endl;
Game N=M;
N.Magic[0]=’A’;N.Magic[3]=’J’;
N.Score-=120;
cout<<N.Magic<<N.Score<<endl;
}
Answer:
TiLeP550
AiLJP430
(1 Mark for each line of output)
15 (e) Find the output of the following program:
SAMPLE PAPER 2010 SET I
2
#include <iostream.h>
void Secret(char Str[ ])
{
for (int L=0;Str[L]!='\0';L++);
for (int C=0;C<L/2;C++)
if (Str[C]=='A' || Str[C]=='E')
Str[C]='#';
else
{
char Temp=Str[C];
15 (e) Find the output of the following program:
SAMPLE PAPER 2010 SET I
2
Str[C]=Str[L-C-1];
Str[L-C-1]=Temp;
}
}
void main()
{
char Message[ ]="ArabSagar";
Secret(Message);
cout<<Message<<endl;
}
ANS:
#agaSbarr
(2 Marks for correct line of output)
16 (e) Find the output of the following
program:
SAMPLE PAPER 2010 SET II
2
#include <iostream.h>
struct Game
{
char Magic[20];int Score;
};
void main()
{
Game M={"Tiger",500};
char *Choice;
16 (e) Find the output of the following
program:
SAMPLE PAPER 2010 SET II
2
Choice=M.Magic;
Choice[4]='P';
Choice[2]='L';
M.Score+=50;
cout<<M.Magic<<M.Score<<endl;
Game N=M;
N.Magic[0]='A';N.Magic[3]='J';
N.Score-=120;
cout<<N.Magic<<N.Score<<endl;
}
ANS:
TiLeP550
AiLJP430
(1 Mark for each line of output)
17 SAMPLE PAPER 2012 SET I
17 SAMPLE PAPER 2012 SET I
17 SAMPLE PAPER 2012 SET I
18 SAMPLE PAPER 2012 SET II
18 SAMPLE PAPER 2012 SET II
THANK
YOU
Download