Login


Lost your password?

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


Shop
CPP All : Preprocessor Directives And Macros
Concept Notes and Resources
Concept Learning Code Sheets

#include directive – Preprocessor for header inclusion #4572

Understanding the purpose of include preprocessor

#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)

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

Exam Papers Problems

File and string related header files #5191

( As In Exam - CBSE12A-2018 )

The following C++ code during compilation reports errors as follows:
Er

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

Required header files #5300

( As In Exam - CBSE12A-2017 )

Anil typed the following C++ code and during compilation he found three error

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

Macro definition for array filling #5304

( As In Exam - CBSE12A-2017 )

Find and write the output of the following C++ program code:
Note: Assu

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

 

Finding required libraries based on functions used #5607

( As In Exam - CBSE12A-2016 )

Ronica Jose has started learning C++ and has typed the following program. Whe

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

Finding and removing Syntax Errors #5610

( As In Exam - CBSE12A-2016 )

Rewrite the following C++ code after removing any/all syntactical errors with

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

Header File Marking #5828

( As In Exam - CBSE12D-2015 )

Observe the following program very carefully and write the names of those he

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

01C #5831

( As In Exam - CBSE12D-2015 )

Observe the following C++ code very carefully and rewrite it after removing

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

Header File Marking #5931

( As In Exam - CBSE12A-2015 )

Observe the following program very carefully and write the name of those head

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

01C-2015 #5933

( As In Exam - CBSE12A-2015 )

after removing any/all syntactical errors with each correction underlined.

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

01B-2017 #6006

( As In Exam - CBSE12D-2017 )

Anil typed the following C++ code and during compilation he found four errors

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

01D #6012

( As In Exam - CBSE12D-2017 )

Find and write the output of the following C++ program code:
Note: Assu

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

01B-2016 #6077

( As In Exam - CBSE12D-2016 )

Jayapriya has started learning C++ and has typed the following program. When

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

01C-2016 #6079

( As In Exam - CBSE12D-2016 )

Rewrite the following C++ code after removing any/all syntactical errors with

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


Quizzes

Concept Notes:2  Code Sheets:5  Exam Paper Problems:13  Quizzes:1
×
Introductory Sessions Beginning to Program Tokens Keyword and Identifiers Data Types Variables and Constants Operators Simple User Input Building Expressions and Formulas Simple Real World Problems Simple If and If Else Multiple-Nested-Ladder of If Else Switch case selection Simple Loops Tricks in Loops - break continue scope Loop Applications - Handling numerals Series printing loops Nested Loops Pattern printing loops Number Varieties and Crunches String Handling (Null Terminated) Strings - string class type Functions (Built-in) Functions - user defined Functions Reference Passing/Returning Arrays Concepts and 1-D Arrays Array Data Management Two dimensional arrays and Matrices Structures Basics Structures passing/returning Display Using IO Manipulation Display Using C Formatting Tricks User Defined Data Types Enumerated Types Preprocessor Directives And Macros Exception Handling Programming Paradigms and OOPs Advantages Abstraction and Encapsulation Polymorphism Inheritance Function Overloading Concepts Function Overloading Varieties Function Overloading Special Cases Defining Classes Creating and Using Class Objects Class Members Accessibility Class Function Types Inline Functions Constant Functions Nesting of Functions Class Members Scope Resolution Static Members in a Class Array of Objects Constructor Concepts Default Constructor Parameterized Constructor Copy Constructor Constructor Overloading Destructors Inheritance Fundamentals Public Derivations Private and Protected Derivations Multiple Inheritance Mult-Level Inheritance Class Nesting Data File Concepts Handling Text Files Handling Binary Files Pointer Concepts Pointer and Arrays Pointers and Functions Object Pointers This Pointer Linked Lists Stacks Queues


Back