Topic Wise Solved Problems Question – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  


Shop
siteicon
CPP: Topicwise Exam Question: functions-built-in siteicon
01B-2017 1

Anil typed the following C++ code and during compilation he found four errors as follows:
(i) Function strlen should have a prototype
(ii) Undefined symbol cout
(iii) Undefined symbol endl
(iv) Function getchar should have a prototype
On asking his teacher told him to include necessary header files in the code.
Write the names of the header files, which Anil needs to include, for successful compilation and execution of the following code:

void main()
{
  char S[] = "Hello";
  for(int i = 0; i<strlen(S); i++)
  S[i] = S[i]+1;
    cout<<S<<endl;
  getchar();
}
CBSE12D-2017

01F 2

Look at the following C++ code and find the possible output(s) from the options (i) to (iv) following it. Also, write the maximum values that can be assigned to each of the variables R and C.
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 R=random(3),C=random(4);
  int MAT[3][3] = {{10,20,30},{20,30,40},{30,40,50}};
  for(int I=0; I<R; I++)
  {
    for(int J=0; J<C; J++)
      cout<<MAT[I][J]<<" ";
    cout<<endl;
  }
}

CBSE12D-2017

01B-2016 1

Jayapriya has started learning C++ and has typed the following program. When she compiled the following code written by her, she discovered that she needs to include some header files to successfully compile and execute it. Write the names of those header files, which are required to be included in the code.

void main()
{
  float A,Number,Outcome;
  cin>>A>>Number;
  Outcome=pow(A,Number);
  cout<<Outcome<<endl;
}
CBSE12D-2016

01F-2016 2

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.
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 I=0;I<=CHANGER;I++)
  {
    for(int J=0;J<=I;J++)
    cout<<CITY[J];
    cout<<endl;
  }
}
(i) (ii)
DELHI

DELHIMUMABAI

DELHIMUMABAIKOLKATA

DELHI

DELHIMUMABAI

DELHIMUMABAIKOLKATA

DELHIMUMABAIKOLKATACHENNAI

(iii) (iv)
MUMABAI

MUMABAIKOLKATA

MUMABAIKOLKATACHENNAI

KOLKATA

KOLKATACHENNAI

CBSE12D-2016

01B 1

Observe the following program very carefully and write the names of those header file(s), which are essentially needed to compile and execute the following program successfully:

typedef char TEXT[80];
void main()
{
  TEXT Str[] = "Peace is supreme";
  int Index=0;
  while (Str[Index]!='\0')
    if (isupper(Str[Index]))
    Str[Index++]='#';
    else
  Str[Index++]='*';
  puts(str);
}
CBSE12D-2015

01F 2

Study the following program and select the possible output(s)from the option (i) to (iv) following it. Also write the maximum and the minimum values that can be assigned to the variable NUM.
Note:

– Assume all required header files are already being includedin 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 I=1;I<=NUM; I++)
  {
    for (int J=NUM;J<=7;J++)
    cout<<TEXT[J];
    cout<<end1;
  }
}
(i)FGHI    (ii) BCDEFGH   (iii) EFGH   (iv) CDEFGH
   FGHI         BCDEFGH         EFGH        CDEFGH
   FGHI                         EFGH
   FGHI                         EFGH
CBSE12D-2015

Output writing – Possible Random Numbers 2

Look at the following C++ code and find the possible output(s) from the options (i) to (iv) following it. Also, write the highest and lowest values that can be assigned in the array A.
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 A[4], C;
  for(C=0; C<4; C++)
  A[C]=random(C+1)+10;
  for(C=3; C>=0; C--)
  cout<<A[C]<<"@";
}

 

(i)   13@10@11@10@             (ii)   15$14$12$10$
(iii) 12@11@13@10@             (iv)  12@11@10@10@

CBSE12A-2018

Required header files 1

Anil typed the following C++ code and during compilation he found three errors as follows:
(i) Function strlen should have prototype
(ii) Undefined symbol cout
(iii) Undefined symbol endl
On asking, his teacher told him to include necessary header files in the code. Write the names of the header files, which Anil needs to include, for successful compilation and execution of the following  code

void main()
{
  char Txt[] = "Welcome";
  for(int C= 0; C<strlen(Txt); C++)
    Txt[C] = Txt[C]+1;
    cout<<Txt<<endl;
}
CBSE12A-2017

Finding required libraries based on functions used 1

Ronica Jose has started learning C++ and has typed the following program. When she compiled the following code written by her, she discovered that she needs to include some header files to successfully compile and execute it. Write the names of those header files, which are required to be included in the code.

void main()
{
  double X,Times,Result;
  cin>>X>>Times;
  Result=pow(X,Times);
  cout<<Result<<endl;
}
CBSE12A-2016

01B-2015 1

Observe the following program very carefully and write the name of those header file (s), which are essentially needed to compile and execute the following program successfully:

typedef char STRING[80];
void main()
{
STRING Txt[] = “We love Peace”;
int Count=0;
while (Txt[Count]!=’\0′)
if (isalpha(Txt[Count]))
Txt[Count++]=’@’ ;
else
Txt[Count++]=’#’ ;
puts (Txt) ;
}

CBSE12A-2015

01F-2015 2

Study the following program and select the possible output(s) from the option (i) to (iv) following it. Also, write the maximum and the minimum values that can be assigned to the variable VAL.
Note:
- Assume all required header files are already being included inthe program.
- random(n) function generates an integer between 0 and n-1.

void main()
{
  randomize();
  int VAL;
  VAL=random(3)+2;
  char GUESS[]="ABCDEFGHIJK";
  for (int I=l;I<=VAL;I++)
{
  for(int J=VAL;J<=7;J++)
  cout«GUESS[J];
  cout«endl;
}
}


(i)       (ii)      (iii)      (iv)
BCDEFGH   CDEFGH    EFGH       FGHI
BCDEFGH   CDEFGH    EFGH       FGHI
                    EFGH       FGHI
                    EFGH       FGHI
CBSE12A-2015