qno 1 (b)

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

Upload: praveenjigajinni

Post on 13-Jan-2017

86 views

Category:

Education


1 download

TRANSCRIPT

Page 1: Qno 1 (b)

XII CBSE Previous Year Question

PaperQUESTION NO

1 (b) 1 OR 2 Marks

Page 2: Qno 1 (b)

1(b) Illustrate the use of #define in C++ to define a macro.

22006 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 valueExample: #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)

Page 3: Qno 1 (b)

21(b) Illustrate the use of inline function in C++ with the

help of an example. 22006 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() void main(){ {….. …….square(3); code copied here { cout<<3 *3 }…… ……….square(5); code copied here {cout<<5 * 5; }} }

Page 4: Qno 1 (b)

3

1(b) Name the header file(s) that shall be needed for successful compilation ofthe following C++ code : 12007 Delhi

void main( ){char Text[40];strcpy(Text, ”AISSCE”);puts(Text);}

Page 5: Qno 1 (b)

31(b) 2007 DANS:

(b) string.hstdio.h

(½ Mark for identifying each correct header file)

Note: Marks are not to be deducted if any additional header file is mentioned

Page 6: Qno 1 (b)

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

Page 7: Qno 1 (b)

41(b) 2007 Outside Delhi

ANS:

(b) string.hstdio.h

(½ Mark for identifying each correct header file)

Note: Marks are not to be deducted if any additional header file is mentioned

Page 8: Qno 1 (b)

51(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

Page 9: Qno 1 (b)

61 (b) Name the header files that shall be needed for the following code: 1

2008 Out side Delhivoid main ( ){char Word [ ] =”Exam”;cout<<setw(20)<<Word;}

Ans: iostream.hiomanip.h

(½ Mark for identifying each correct header file)Note: Ignore any other header files, if mentioned

Page 10: Qno 1 (b)

71 (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)

Page 11: Qno 1 (b)

81 (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)

Page 12: Qno 1 (b)

91 (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.hORiomanip.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.

Page 13: Qno 1 (b)

101(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.hORiomanip.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.

Page 14: Qno 1 (b)

111(b) Write the names of the header files, which is/are essentially required to run/ execute the

following C++ code: 12011 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 ;}}

Page 15: Qno 1 (b)

111(b) 2011 Delhi

Ans iostream.hctype.h

(½ Mark for writing each correct header file)

Page 16: Qno 1 (b)

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

Page 17: Qno 1 (b)

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.hctype.h

(½ Mark for writing each correct header file)

Page 18: Qno 1 (b)

131(b) Write the names of the header files to

which the following belong: 1Sample paper 2009 Set I

(i) strcmp()(ii) fabs()

ANS (b) (i) string.h (ii) math.h ( ½ Mark for mentioning each correct header filename)

Page 19: Qno 1 (b)

141(b) Write the names of the header files to

which the following belong: 1Sample paper 2009 Set II

(i) frexp()(ii) isalnum()

ANS (b) (i) math.h (ii) ctype.h ( ½ Mark for mentioning each correct header filename)

Page 20: Qno 1 (b)

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

Page 21: Qno 1 (b)

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)

Page 22: Qno 1 (b)

17(b) Which C++ header file(s) are essentially required to be included to run/execute the following C++ code:

1Sample 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)

Page 23: Qno 1 (b)

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)

Page 24: Qno 1 (b)

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)

Page 25: Qno 1 (b)

THANK YOU