Tuesday

Computer Science with C++ - Important Questions - class 12 - cbse

 Question 41:

Find the output of the following program

#include<iostream.h>
 #include<ctype.h>
 void Encodei(char Info[],int N);
 void main()
 {
 char Memo[]="Justnow";
Encode(Memo, 2);
count<<Memo<<endl;
}
void Encodeichar Info[],int N)
{
 for(int I = 0;Info[I]!= "\0"; I++) 
i f ( I %2= =0 )
 Info[I]=Info[I]-N;
 else 
if(is lower (Info[I]); 
Info[I]=toupper(Info[I]) 
else
 Info[I]=Info[I]+N;
 } Delhi 2009

Answer:
Output

HUqTlOu

Question 42:
Find the output of the following program

#include<iostream.h> 
#include<ctype.h> 
void Secretlchar Msg[],int N);
void main()
{
char SMS[]="rEPorTmE": 
Secret(SMS, 2): 
cout<<SMS<<endl:
}
void Secret(char Msg[],int N)
{
for(int C=O; Msg [C]!="\0”;C++) 
if ( C%2 ==0)
Msg[C]=Msg[C] + N; 
else if(isupper(Msg[C] ) ) 
Msg[C]=tolower(Msg[C]) ) : 
Msg[C]=Msg[C]-N;
} All India 2009

Answer:
Output

teRmttoe

3 Marks Questions

Question 43:
Find the output of the following program

#include<iostream.h> 
void ChangeArray(int Number, int ARR[],int Size)
{
 for(int L= 0; L<Size; L++) 
if ( L<Number)
 ARR[L]+=L; 
else
 ARR[L]*=L;
 void Show(int ARR[],int size)
{
for( int L=0; Ksize; L++)
( L%2 !=0)?cout<<ARR[L]<<"#" : 
cout<<ARR[L]<<endl;
}
void main()
{
int Array[]={30,20,40,10,60,50}; 
ChangeArray(3, Array, 6);
Show(Array, 6);
} Delhi 2011

Answer:
Output

30
21#42
30#240
250#

Question 44:
Find the output of the following program

#include<iostream.h> 
struct Dress 
{
 int size,cost,Tax,Total_Cost;
 };
 void change(Dress &S, int Flag=1)
 {
 if(Flag ==1) S.cost +=20;
 S.Total_Cost=S.cost+
 S.cost*S.Tax/100;
}
 void main()
{
 Dress S1=(40, 580, 8},S2 ={34, 550, 101; change(S1) ;
 cout<<S1.size<<","<<S1.cost .    <<","<<S1,Total_Cost<<endl;
 change(S2, 2);
 cout<<S2.size<<" ,''<<S2.cost <<", "<<S2 .Total_Cost<<endl ;
 } Delhi 2011C

Answer:
Output

40, 600, 648 
34, 550, 605

Question 45:
Find the output of the following program

#include<iostream.h> 
struct POINT
{
 int x, y, z;
 };
 void StepIn(POINT &P, int Step=1)
 {
 P.x+=Step;
 P.y-=Step;
 P.z+=Step;
}
 void main()
 {
 POINT P1={15, 25, 5},
 P2={10, 30, 201;
 StepIn(P1) ;
 StepIn(P2, 4);
 cout<<Pl.x<<', '<<Pl.y<<', '
 <<P2.z<<endl;
} Delhi 2010

Answer:
Output

16,  24, 6 
14, 26, 24 
26, 14, 36

Question 46:
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 Move0ut(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} ;
Moveln (T1) ;
Move0ut(T2, 5); 
cout<<Tl.x<<', '<<Tl.y<<', ' <<Tl.z<<endl;
cout<<T2.x<<', '<<T2.y<<', '<<T2. z<<endl ;
Moveln (T2, 10); 
cout<<T2.x<<' , '<<T2.y<<', ' <<T2.z<<endl ;
} All India 2010

Answer:
Output

11, 19, 4 
25, 15, 35 
35, 5,  25

0 comments:

Post a Comment

Thanks for leaving a comment. As soon as it's approved, it will appear.