Professional Documents
Culture Documents
XII CBSE Previous Year Question Paper: Question No 1 (B) 1 OR 2 Marks
XII CBSE Previous Year Question Paper: Question No 1 (B) 1 OR 2 Marks
Year Question
Paper
QUESTION NO
1 (b)
1 OR 2 Marks
1
(b) Illustrate the use of #define in C++ to define a
macro.
2
2006 Delhi
ANS: #define is a preprocessor directive that is used to
define a symbolic constant. The symbolic constant
defined, replaces the word / statement wherever it
appears in the program as a macro substitution.
Syntax : #define symbolic_name value
Example: #define Pi 3.14
#define WELCOME cout<<Hello World !\n;
(Full 2 marks for illustrating the concept of #define
using example)
OR
(1 mark if only definition is written)
2
1(b) Illustrate the use of inline function in C++ with the
help of an example. 2
2006 Outside Delhi
.
square(5); code copied here {cout<<5 * 5; }
}
}
3
1(b) 2007 D
ANS:
(b)
string.h
stdio.h
( Mark for identifying each correct
header file)
Note: Marks are not to be deducted if any
additional header file is mentioned
4
1(b) Name the header file(s) that shall be needed for
successful compilation of the following C++ code.
2007 Outside Delhi
void main ( )
{
char String [20];
gets (String);
strcat (String, CBSE);
puts (String);
}
4
1(b)
ANS:
(b) string.h
stdio.h
( Mark for identifying each correct header
file)
Note: Marks are not to be deducted if any
additional header file is mentioned
5
1(b) Name the header files that shall be needed for
the following code
1
2008 Delhi
void main ( )
{
char String [ ] = Peace;
cout<<setw (20) << String;
}
Ans: iostream.h
iomanip.h
( Mark for identifying each correct header file)
Note: Ignore any other header files, if mentioned
6
1 (b) Name the header files that shall be
needed for the following code:
1
2008 Out side Delhi
void main ( )
{
char Word [ ] =Exam;
cout<<setw(20)<<Word;
}
Ans: iostream.h
iomanip.h
( Mark for identifying each correct header file)
Note: Ignore any other header files, if mentioned
7
1 (b) Write the names of the header files to which the
following belong:
1
2009 Delhi
(i) puts( )
(ii) sin( )
8
1 (b) Write the names of the header files to which the
following belong:
1
2009 Outside Delhi
(i) setw( )
(ii) sqrt( )
9
1 (b) Which C++ header file(s) will be essentially
required to be included to run/execute the following
C++ code?
1
2010 Delhi
void main( )
{
int Eno=123, char Ename[ ]=Rehan Swamp;
cout<<setw(5)<<Eno<<setw(25)<<EName<<endl;
10
1(b) Which C++ header file(s) will be essentially
required to be included to run/ execute the
following C++ code:
1
2010 Outside Delhi
void main()
{
int Rno=24; char Name[] =Amen Singhania;
cout<<setw(lO)<<Rno<<setw(20)<<Name<<endl;
}
Ans. (i) iostream.h (ii) iomanip.h
OR
iomanip.h - (As iostream.h is included in iomanip.h)
( Mark for writing each correct header file)
OR
(Full 1 Mark for mentioning only iomanip.h )
Note: Ignore any other header files, if mentioned.
11
1(b) Write the names of the header files, which is/are essentially required to run/ execute the
following C++ code:
1
2011 Delhi
void main ( )
{
char C, String [ ] = "Excellence Overload";
for (int I=0; String [ I ] ! = '\ 0'; I ++ )
if (String [I] ==' ')
cout<<end1;
else
{
C=toupper(String[I]);
cout<<C ;
}
}
11
1(b) 2011 Delhi
Ans iostream.h
ctype.h
( Mark for writing each correct header file)
12
(b) Write the names of the header files, which is/are essentially required to run/ execute
the following c++ code:
1
2011 Outside Delhi
void main ( )
{
char CH,Text[ ] ="+ve Attitude";
for (int I=0 ; Text[I] ! ='\0' ;I++)
if (Text[I]== ' ')
cout<<end1;
else
{
CH=toupper (Text [I]) ;
cout<<CH;
}
}
12
(b) Write the names of the header files, which is/are essentially
required to run/ execute the following c++ code:
1
2011 Outside Delhi
Ans
iostream.h
ctype.h
( Mark for writing each correct header file)
13
1(b) Write the names of the header files to
which the following belong:
1
Sample paper 2009 Set I
(i) strcmp()
(ii) fabs()
14
1(b) Write the names of the header files to
which the following belong:
1
Sample paper 2009 Set II
(i) frexp()
(ii) isalnum()
15
(b) Which C++ header file(s) will be essentially required
to be included to run /execute the following C++ code:
1
2010 Sample Paper Set I
void main()
{
char Msg[ ]="Sunset Gardens";
for (int I=5;I<strlen(Msg);I++)
puts(Msg);
}
ANS (b) (i) string.h (ii) stdio.h
( Mark for mentioning each correct header filename)
16
(b) Write the names of the header files to which the
following belong:
1
2010 Sample Paper Set II
(i) frexp() (ii) isalnum()
ANS :
(b) (i) math.h (ii) ctype.h
( Mark for mentioning each correct header filename)
17
(b) Which C++ header file(s) are essentially required to be included to run/execute the following C++ code:
1
Sample paper 2012 Set I
void main ( )
{
int Last =25 ;
for ( int C=9 ; C <= Last ; C ++ )
cout<< C << : <<sqrt ( C ) <<endl;
}
ANS :
(b) (i) iostream.h ( for cout ) (ii) math.h (for sqrt)
( Mark for mentioning each correct header filename)
18
(b) Write the names of the header files to which the
following belong:
1
2010 Sample Paper Set II
(i) exp() (ii) strcmpi()
ANS :
(b) (i) math.h (ii) string.h
( Mark for mentioning each correct header filename)
19
(b) Which of the header file(s) are essentially required to be included to run / execute the following C+
+ source code. (Note: Do not include any header file which is / are not required ) 1
2012 Outside Delhi
void main ( )
{
char TEXT [ ] = Something ;
cout<< Remaining SMS Chars :
<< 160-strlen(TEXT)<<endl;
ANS :
(b) (i) iostream.h (for cout)(ii) string.h (for strlen ( ) )
( Mark for mentioning each correct header filename)
THANK YOU