Friday

Important Question Answers - Class 12 - CS with C++-CBSE

 Question 11:

Which C++ header file(s) will be essentially required to be included to run/execute the following C++ code?

void main() 
{
char Name[20]; 
cin>>Name; 
toupper (Name[0]); 
cout<<Name<<endl;
} Delhi 2011C

Answer:

<iostream.h>→C0ut,cin 
<ctype.h>→ toupper()

Question 12:
Which C++header file(s) will be essentially required to be included to run/execute the following C++ code?

void main()
{
int Eno=123, char EName[]
="Rehan Swarop"; 
cout<<setw(5)<<Eno<setw(25)
<<EName<<endl;
) Delhi 2010

Answer:

<iomanip.h> → setw() 
Ciostream.h> → Cout

Question 13:
Which C++header file(s) will be
essentially required to be included to run/execute the following C++ code?

void main()
{ 
int Rno=24;
char Name[]="Aman Singhania";
cout<<setw(10X<Rno<<setw(20)
<<Name<<endl;
} All India 2010

Answer:

<iomanip.h>→setw()
<iostream.h>→cout

Question 14:
Find and write the output of the following C++ program code:
NOTE Assume all required header files are already included in the program.

# define Diff(N1,N2)
((N1>N2)?N1-N2:N2-N1)
void main ()
{
int A,B,NUM[] = {10,23,14,54,321 ; 
for(int CNT=4; CNT>0; CNT--)
{
A=NUM[CNT] ;
B=NUM[CNT-1] ; 
cout<<Diff(A,B)<<'#' :
}
} All India 2017

Answer:

Output
22#40#9#13#

Question 15:
Look at the following C++ code and find the possible outputs(s) from the options (i) to (iv) following it. Also, .write the maximum values that can be assigned to each of the variables N and M.
NOTE

• Assume all the required header files are already being included in the code.
• The function random(n) generates an integer between 0 and n-1.

void main()
 {
 randomize() ;
 int N=random(3), M=random(4);
 int DOCK[3][3]
 = {{1,2,3},{2,3,4},1{3,4,5,}}:
 for (int R=0; R<N; R++)
 {
 for(int C=0; C<M; C++)
 cout<<DOCK[R][C]<<" cout<<endl ;
(i)(ii)
1       2      31       2      3
2      3      42      3      4
3     4       5
(iii)(iv)
1       21          2
2      32         3
3         4

Answer:
Possible Outputs: (ii) and (iii)
Maximum value of N is 2.
Minimum value of N is 0.
Maximum value of M is 3.
Minimum value of M is 0.

Question 16:
Find and write the output of the following C++ program code: All India 2016
NOTE Assume all required header files are already included in the program.

typedef char TEXT[80]; 
void JumbleUp(TEXT T)
{
int L=strlen(T);
for(int C=0; C<L-1; C+=2)
{
char CT=T[C]:
T[C]=T[C+1] :
T[C+1]=CT;
}
for(C=1: C<L; C+=2)
i f(T [C]>= ’ M ' && T[C]<='U' )
T[C]='@' :
}
void main()
{
TEXT Str="HARMONIOUS";
JumbleUp(Str) ;
cout<<Str<<endl :
}

Answer:

The output will be
AHM@N@OIS@

Question 17:
Look at the following C++ code and find the possible output(s) from the options (i) to (iv) following it. Also, write the maximum and the minimum values that can he assigned to the variable PICKER. All India 2016
NOTE Assume all required header files are already being included in the code. The function random(n) generates an integer between 0 and n -1.

void main()
 {
 int PICKER:
 PICKER=1+random(3) ;
 char COLOURC][5]={"BLUE","PINK”, "GREEN”,"RED"):
 for(int I=0;I<=PICKER; I++)
 {
 for(int J=0;J<=I; J++)
 cout<<COLOUR[J] :
 cout<<endl:
 }
 }
(i)(ii)(iii)(iv)
PINKBLUEGREENBLUE
PINKGREENBLUEPINKGREENREDBLUEPINK
PINKGREENBLUEPINKBLUEPINK
RED

GREEN

BLUEPINK

GREENRED

GREEN

Answer:
The possible outputs are (ii) and (iv)
Minimum value of PICKER = 1
Maximum value of PICKER = 3

Question 18:
Find and write the output of the following C++ program code: Delhi 2016 NOTE Assume all required header files are already included in the program,

typedef char STRING [80];
void MIXITNOW(STRING S)
{
int Size=strlen(S) :
for(int I=0; I<Size-1; I+=2)
Char WS = S[I] ;
S[I] = S[I+1]:
S[I+1]=WS;
}
for( I=1 ; I<Size; I+=2)
if(S[I]>=’M’ && S[I]<=’U’)
S[I]=’@’;
}
void main( )
{
STRING Word = “CRACKAJACK”;
MIXITNOW(Word) ;
cout<<Word<<endl;

Answer:

Output
RCCAAKAJKC

Question 19:
Look at the following C++ code and find the possible output(s) from the options (i) to (iv) following it. Also, write the maximum and the minimum values that can be assigned to the variable CHANGER. Delhi 2016
NOTE Assume all the required header files are already being included in the code. The function random(n) generates an integer between 0 and n -1.

void main()
 {
 randomize();
 int CHANGER;
 CHANGER = random(3);
 char CITY[ ][25] = {"DELHI", "MUMBAI","KOLKATA","CHENNAI"};
 for(int 1=0; I<=CHANGER; I++)
 {
 forlint J=0; J<=I; J++)
 cout<<CITY[J] ;
 cout<< endl;
Important Questions for Class 12 Computer Science (C++) - C++ Revision Tour-1
Answer:

The possible outputs are (i) and (ii)
Minimum value of CHANGER = 0
Maximum value of CHANGER = 2

Question 20:
Study the following program and select the possible output(s) from the options (i) to (iv) following 
it. Also, write the maximum and the minimum values that can be assigned to the variable NUM. 
Delhi 2015
NOTE Assume all required header files are already being included in the program, 
random(n) function generates an integer between 0 and n-1.
void main()
 {
 randomize(); 
int NUM;
 NUM=random(3)+2;
 char TEXT[]="ABCDEFGHIJK";
 for(int 1=1; 1<=NUM; I++)
 for(int J=NUM; J<=7; J++) 
cout<<TEXT( J ) ;
cout<<endl ;
}
}

(i) FGHI       (ii) BCDEFG          (iii) EFGH       (iv) CDEFG
H                                                           H
FGHI              BCDEFG                  EFGH               CDEFG
H                                                           H
FGHI                                                EFGH
FGHI                                                EFGH

Answer:
The possible outputs are (iii) and (iv)
Minimum value of Num = 2
Maximum value of NUM = 4

0 comments:

Post a Comment

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