Presentation is loading. Please wait.

Presentation is loading. Please wait.

XII CBSE Previous Year Question Paper QUESTION NO 1 (b) 1 OR 2 Marks.

Similar presentations


Presentation on theme: "XII CBSE Previous Year Question Paper QUESTION NO 1 (b) 1 OR 2 Marks."— Presentation transcript:

1 XII CBSE Previous Year Question Paper QUESTION NO 1 (b) 1 OR 2 Marks

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

3 2 1( b) Illustrate the use of inline function in C++ with the help of an example. 2 2006 Outside Delhi The inline functions are a C++ enhancement designed to speed up the program. The coding of normal function and inline functions is similar except that inline functions definition starts with keyword inline. The compiler replaces the function call statement with the function code itself this process is called as expansion and then compiles the entire code. For example: void main() { …..……. square(3); code copied here{ cout<<3 *3 } ……………. square(5); code copied here {cout<<5 * 5; }}

4 3 1(b) Name the header file(s) that shall be needed for successful compilation of the following C++ code : 1 2007 Delhi void main( ) { char Text[40]; strcpy(Text, ”AISSCE”); puts(Text); }

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

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

7 4 1(b) 2007 Outside Delhi 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

8 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

9 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

10 7 1 (b) Write the names of the header files to which the following belong: 1 2009 Delhi (i) puts( ) (ii) sin( ) Ans (i) stdio.h (ii) math. h (½ Mark for writing each correct header file)

11 8 1 (b) Write the names of the header files to which the following belong: 1 2009 Outside Delhi (i) setw( ) (ii) sqrt( ) Ans (i) iomanip.h (ii) math.h (½ Mark for writing each correct header file)

12 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; 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.

13 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.

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

15 11 1(b)2011 Delhi Ans iostream.h ctype.h (½ Mark for writing each correct header file)

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

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

18 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() ANS (b) (i) string.h (ii) math.h ( ½ Mark for mentioning each correct header filename)

19 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() ANS (b) (i) math.h (ii) ctype.h ( ½ Mark for mentioning each correct header filename)

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

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

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

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

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

25 THANK YOU


Download ppt "XII CBSE Previous Year Question Paper QUESTION NO 1 (b) 1 OR 2 Marks."

Similar presentations


Ads by Google