Login


Lost your password?

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


Shop
Concept Notes and Resources

There are many built-in functions in C++ which can be used by a programmer as needed. To allow a build-in function or usage of some pre-fixed declarations C++ provides a concept of header files. Header file primarily contains the function prototypes of built-in functions so that its type checking can be performed and related library […]

As the name signifies, pre-processor directives are instructions given to compiler which it has to run before main code compilation will begin. You must be frequently seeing #include as the top of most C++ program codes. It is nothing but a pre-processor directive to tell compiler that definitions of certain classes, function and objects have […]

Concept Learning Code Sheets
#define directive – Preprocessor for Names to constant replacement #4580 

Understanding the purpose of #define pre-processor directive.

#define directive as Macros Expressions #4585 

Understanding the purpose of #define pre-processor directive to be used as macros or use of replacement action for expressions

#define Macros Nesting #4587 

Understanding how #define macros can be nested (use of one macros expression as a part of another macros expression)

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;
}

Solved Problems
File and string related header files #5191 

The following C++ code during compilation reports errors as follows:
Error: ‘ofstream’ not declared
Error: ‘strupr’ not declared
Error: ‘strcat’ not declared
Error: ‘FIN’ not declared
Write the names of the correct header files, which must be included to compile the code successfully:

void main()
{
  ofstream FIN("WISH.TXT");
  char TEXT2[]="good day";
  char TEXT1[]="John!";
  strupr(TEXT2);
  strcat(TEXT1, TEXT2);
  FIN<<TEXT1<<endl;
}
The following C++ code during compilation reports errors as follows: Error: ‘ofstream ...
Required header files #5300 

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;
}
Anil typed the following C++ code and during compilation he found three errors as follows ...
Macro definition for array filling #5304 

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,32};
  for(int CNT =4; CNT>0; CNT--)
  {
    A=NUM[CNT];
    B=NUM[CNT-1];
    cout<<Diff(A,B)<<'#';
  }
}

 

Find and write the output of the following C++ program code: Note: Assume all required he ...
Finding required libraries based on functions used #5607 

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;
}
Ronica Jose has started learning C++ and has typed the following program. When she compil ...
Finding and removing Syntax Errors #5610 

Rewrite the following C++ code after removing any/all syntactical errors with each correction underlined.

Note: Assume all required header files are already being included in the program.

#define Formula(a,b) = 2*a+b
void main()
{
  float X=3.2;Y=4.1;
  Z=Formula(X,Y);
  cout<<'Result='<<Z<<endl;
}
Rewrite the following C++ code after removing any/all syntactical errors with each correct ...
Header File Marking #5828 

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);
}
Observe the following program very carefully and write the names of those header file(s), ...
01C #5831 

Observe the following C++ code very carefully and rewrite it after removing any/all syntactical errors with each correction underlined.
Note: Assume all required header files are already being included in the program.

#Define float Max=70.0;
void main()
{
  int Speed
  char Stop='N';
  cin>>Speed;
  if Speed>Max
    Stop='Y';
  cout<<Stop<<end;
}
Observe the following C++ code very carefully and rewrite it after removing any/all synta ...
Header File Marking #5931 

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) ;
}

Observe the following program very carefully and write the name of those header file (s), ...
01C-2015 #5933 

after removing any/all syntactical errors with each correction underlined.
Note: Assume all required header files are already being included in the program.

#Define float MaxSpeed=60.5;
void main()
{
  int MySpeed
  char Alert='N' ;
  cin»MySpeed;
  if MySpeed>MaxSpeed
  Alert='Y' ;
  cout<<Alert<<endline;
}
after removing any/all syntactical errors with each correction underlined. Note: Assume a ...
01B-2017 #6006 

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();
}
Anil typed the following C++ code and during compilation he found four errors as follows: ...
01D #6012 

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

#define Big(A,B) (A>B)?A+1:B+2
void main()
{
  char W[] = "Exam";
  int L=strlen(W);
  for(int i =0; i<L-1; i++)
     W[i] = Big(W[i],W[i+1]);
  cout<<W<<endl;
}
Find and write the output of the following C++ program code: Note: Assume all required he ...
01B-2016 #6077 

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;
}
Jayapriya has started learning C++ and has typed the following program. When she compiled ...
01C-2016 #6079 

Rewrite the following C++ code after removing any/all syntactical errors with
each correction underlined.
Note: Assume all required header files are already being included in the program.

#define Equation(p,q) = p+2*q
void main()
{
  float A=3.2;B=4.1;
  C=Equation(A,B);
  cout<<'Output='<<C<<endl;
}
Rewrite the following C++ code after removing any/all syntactical errors with each correc ...
01B-2019S #6944 

Write the names of the correct header files, which must be included in the following C++ code to compile the code successfully:

void main ()
{
  char L[]="CS 2018";
  int N=strlen(L);
  cout<<L[N-1];
}
Write the names of the correct header files, which must be included in the following C++ c ...
01C-2019S #6951 

Rewrite the following C++ Program after removing any/all syntactical error(s). Underline each correction done in the code:

Note: Assume all required header files are already included in the profram.

 

#define Area(L,B) = L*B
structure Recta
{
  int Length, Breadth;
};
  void main()
{
  Recta R= [10, 15];
  cout<<Area(Length.R, Breadth.R);
}
Rewrite the following C++ Program after removing any/all syntactical error(s). Underline e ...
Exam Questions
CBSE12A-2018-01B  File and string related header files #5191 

The following C++ code during compilation reports errors as follows:
Error: ‘ofstream’ not declared
Error: ‘strupr’ not declared
Error: ‘strcat’ not declared
Error: ‘FIN’ not declared
Write the names of the correct header files, which must be included to compile the code successfully:

void main()
{
  ofstream FIN("WISH.TXT");
  char TEXT2[]="good day";
  char TEXT1[]="John!";
  strupr(TEXT2);
  strcat(TEXT1, TEXT2);
  FIN<<TEXT1<<endl;
}
The following C++ code during compilation reports errors as follows: Error: ‘ofstream ...
CBSE12A-2017-01B  Required header files #5300 

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;
}
Anil typed the following C++ code and during compilation he found three errors as follows ...
CBSE12A-2017-01D  Macro definition for array filling #5304 

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,32};
  for(int CNT =4; CNT>0; CNT--)
  {
    A=NUM[CNT];
    B=NUM[CNT-1];
    cout<<Diff(A,B)<<'#';
  }
}

 

Find and write the output of the following C++ program code: Note: Assume all required he ...
CBSE12A-2016-01B  Finding required libraries based on functions used #5607 

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;
}
Ronica Jose has started learning C++ and has typed the following program. When she compil ...
CBSE12A-2016-01C  Finding and removing Syntax Errors #5610 

Rewrite the following C++ code after removing any/all syntactical errors with each correction underlined.

Note: Assume all required header files are already being included in the program.

#define Formula(a,b) = 2*a+b
void main()
{
  float X=3.2;Y=4.1;
  Z=Formula(X,Y);
  cout<<'Result='<<Z<<endl;
}
Rewrite the following C++ code after removing any/all syntactical errors with each correct ...
CBSE12D-2015-01B  Header File Marking #5828 

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);
}
Observe the following program very carefully and write the names of those header file(s), ...
CBSE12D-2015-01C  01C #5831 

Observe the following C++ code very carefully and rewrite it after removing any/all syntactical errors with each correction underlined.
Note: Assume all required header files are already being included in the program.

#Define float Max=70.0;
void main()
{
  int Speed
  char Stop='N';
  cin>>Speed;
  if Speed>Max
    Stop='Y';
  cout<<Stop<<end;
}
Observe the following C++ code very carefully and rewrite it after removing any/all synta ...
CBSE12A-2015-01B  Header File Marking #5931 

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) ;
}

Observe the following program very carefully and write the name of those header file (s), ...
CBSE12A-2015-01C  01C-2015 #5933 

after removing any/all syntactical errors with each correction underlined.
Note: Assume all required header files are already being included in the program.

#Define float MaxSpeed=60.5;
void main()
{
  int MySpeed
  char Alert='N' ;
  cin»MySpeed;
  if MySpeed>MaxSpeed
  Alert='Y' ;
  cout<<Alert<<endline;
}
after removing any/all syntactical errors with each correction underlined. Note: Assume a ...
CBSE12D-2017-01B  01B-2017 #6006 

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();
}
Anil typed the following C++ code and during compilation he found four errors as follows: ...
CBSE12D-2017-01D  01D #6012 

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

#define Big(A,B) (A>B)?A+1:B+2
void main()
{
  char W[] = "Exam";
  int L=strlen(W);
  for(int i =0; i<L-1; i++)
     W[i] = Big(W[i],W[i+1]);
  cout<<W<<endl;
}
Find and write the output of the following C++ program code: Note: Assume all required he ...
CBSE12D-2016-01B  01B-2016 #6077 

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;
}
Jayapriya has started learning C++ and has typed the following program. When she compiled ...
CBSE12D-2016-01C  01C-2016 #6079 

Rewrite the following C++ code after removing any/all syntactical errors with
each correction underlined.
Note: Assume all required header files are already being included in the program.

#define Equation(p,q) = p+2*q
void main()
{
  float A=3.2;B=4.1;
  C=Equation(A,B);
  cout<<'Output='<<C<<endl;
}
Rewrite the following C++ code after removing any/all syntactical errors with each correc ...
CBSE12A-2019-A01B  01B-2019S #6944 

Write the names of the correct header files, which must be included in the following C++ code to compile the code successfully:

void main ()
{
  char L[]="CS 2018";
  int N=strlen(L);
  cout<<L[N-1];
}
Write the names of the correct header files, which must be included in the following C++ c ...
CBSE12A-2019-A01C  01C-2019S #6951 

Rewrite the following C++ Program after removing any/all syntactical error(s). Underline each correction done in the code:

Note: Assume all required header files are already included in the profram.

 

#define Area(L,B) = L*B
structure Recta
{
  int Length, Breadth;
};
  void main()
{
  Recta R= [10, 15];
  cout<<Area(Length.R, Breadth.R);
}
Rewrite the following C++ Program after removing any/all syntactical error(s). Underline e ...
Quizzes

Concept Notes:3  Code Sheets:5  Solved Problems:15  Exam Questions:15  Quizzes:1
Back