Find Your Free Essay Examples

Important Questions Class 12 Computer Science C C Revision Tour

Free PDF download of Important Questions for CBSE Class 12 Computer Science (C++) Chapter 1 C++ Revision Tour prepared by expert Computer Science (C++) teachers from latest edition of CBSE(NCERT) books, On StudySolver.Org to score more marks in CBSE board examination.

Previous Years Examination & Important Questions 2 Marks Questions Question 1: Write the type of C++ tokens (keywords and user defined identifiers) from the following:  All Indio 2017

Question 2: Out of the following, find those identifiers, which cannot be used for naming Variable, Constants or Functions in a C++ program:  Delhi 2016 Cost, Price*Qty, float, Switch, Address One. Delete, Number12, do Аnswer: Price*Qty, float, do and Address One cannot be used for naming variables, constants or functions in a C++ program. Question 3: Rewrite the following C++ code after removing any/all syntactical errors with each correction underlined.  Delhi 2016 NOTE:  Assume all required header files are already being included in the program.

Question 4: Out of the following, find those identifiers, which cannot be used for naming Variables, Constants or Functions in a C++ program:  All India 2016 Fatal*Tax, double, Case, My Name, NeW, switch, Column31,_Amount Аnswer: Fatal*Tax, double, My Name, switch cannot be used for naming variables, constants or functions in a C++program. Question 5: Rewrite the following C++ code after removing any/all syntactical errors with each correction underlined.  All India 2016 NOTE Assume all required header files are already being included in the program.

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

Question 7: Find the correct identifiers Out of the following, which can be used for naming Variable, Constants or Functions in a C ++ program:  Delhi 2015 While, for, Float, new, 2ndName, A%B, Amountl2, _Counter Аnswer: The correct identifiers are as follows: While, Float, Amount 12 and_Counter Question 8: Find the correct identifiers out of the following, which can be used for naming Variables, Constants or Functions in a C++ For, while, INT, NeW, delete, 1stName, Add+Subtract, name1 Аnswer: The correct identifiers are as follows: For, INT, NeW and name1 Question 9: Observe the following C++ code carefully and rewrite the same after removing all the syntax error(s) present in the code. Ensure that you underline each correction in the code.  All India 2013 Important Note: (i) All the desired header files are already included, which are required to run the code. (ii) Correction should not change the logic of the program.

Question 10: Observe the following OH- code carefully and rewrite the same after removing all the syntax error(s) present in the code. Ensure that you underline each correction in the code. Important Note: (i) All the desired header files are already included, which are required to run the code. (ii) Correction should not change the logic of the program.  Delhi 2013

Question 11: Give the difference between the type casting and automatic type conversion. Also, give a suitable C++ code to illustrate both.  All India 2012,2011 Delhi 2010 Аnswer: Type casting It is used by the programmer to convert the value of one type to another type, e.g. float X=(float) 15/6: Automatic type conversion It is automatically done by the compiler itself wherever required. e.g. float X=3; Question 12: What is the difference between local variable and global variable? Also, give a suitable C++ code to illustrate both.  Delhi 2011 Аnswer: A variable which is declared within the body of a function and accessible only within the function is known as local variable. A variable which is declared outside any function and accessible to all functions in a program is known as global variable. To illustrate this, below is given programming example:

Question 13: What is the function of typedef in C++? Also, give a suitable C++ code to illustrate it.  Delhi 2011C Аnswer: typedef keyword is used to assign alternative names to existing types. e.g. typedef int in; Now, whenever we want to declare a variable of type integer, rather than using int we can use ‘in’ keyword in place of int. e.g.

Question 14: What is the function of #define keyword? Give an example to illustrate its use.  Delhi 2009C Аnswer: #define keyword is a preprocessor directive that is used to define a macro or a symbolic constant. Syntax #define macroname expression or #define symbolic constant-value e.g. #define Area(R) 3.14*R*R #define Max 100

1 Mark Questions Question 1: 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.

All India 2016 Аnswer: Ciostream. h>→cout, cin →pow() Question 2: 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 this code.

Аnswer: →cout, cin →pow( ) Question 3: Ahmad has started learning C++ and has typed the following program. When he compiled the following code written by him, he discovered that he 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.

Аnswer: →cout, cin →sin( ) Question 4: Observe the following C ++ code and write the name(s) of the header file(s), which will be essentially required to run it in a C ++ compiler.

Аnswer: → cout,cin →sqrt( ) Question 5 : Observe the following C ++ code and write the name(s) of the header file(s), which will be essentially required to run it in a C++ compiler.

Аnswer: → cout, cin →abs( ) Question 6: Name the header file(s), which are essentially required to run the following program segment.

Аnswer: →cout,cin → islower( ); i supper( ) Question 7: Write the names of the header files to which the following belong:

Аnswer: puts( )→ sin( )→ Question 8: Write the names of the header files to which the following belong:

Аnswer: setw( )→ sqrt( )→ Question 9: Write the names of the header files to which the following belong:

Аnswer: puts( )→ randomize( )→   2 Marks Questions Question 10: 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.

Question 11: 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.

Question 12: Write the output of the following C ++ program code: NOTE Assume all required header files are already being included in the program.

Аnswer: The output will be 10, 8 20, 8 Question 13: 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.

Question 14: Write the output of the following C++ program code: NOTE Assume all required header files are already being included in the program.

Аnswer: This program code will give error, i.e Y is undefined symbol. Question 15: Write the output of the following C ++ program code: NOTE Assume all required header files are already being included in the program.

Аnswer: The output will be: # # # * * * * & & & & & Question 16: Write a user defined function DIVT( ) which takes an integer as parameter and returns whether it is divisible by 13 or not. The function should return 1 if it is divisible by 13, otherwise it should return 0.  All India 2014C Аnswer:

Question 17: What is the difference between actual and formal parameter? Give a suitable example to illustrate using a C++ code. Delhi 2014 or Difference between the actual parameters and formal parameters. Also, give a suitable C++ code to illustrate both. Delhi 2013C; Delhi 2012; All India 2009 Аnswer: Differences between actual and formal parameters are as follows:

Question 18: Find the output of the following program:  All India 2014C

Аnswer: Output 20#300#10# 602  [email protected]  3 0  [email protected] @ 6020 300 300 3000$ Question 19: What is the benefit of using default parameter/argument in a function? Give a suitable example to illustrate it using C++ code.  All Indio 2013 Аnswer: A default parameter is a function parameter that has a default value provided to it. If the user does not supply a value for this parameter, the default value will be used. If the user supply a value for the default parameter, the user-supplied value is used. Consider the following program:

Question 20: What is the benefit of using function prototype for a function? Give a suitable example to illustrate it using a C++ code Delhi 2013 Аnswer: The function prototype serve to ensure that calls to the function are made with the proper number and types of arguments. In the case of function overloading, the different prototypes serve to distinguish which version of the function to call. The computer will complain with an error, if no function prototype is found for any particular call to function.

Question 21: Find out the expected correct output(s) from the options (i) to (iv) for the following C++ code. Also, find out the minimum and the maximum value that can be assigned to the variable stop used in the code.

Аnswer: Expected output : (ii), (iii) Minimum value is 6 Maximum value is 8 Question 22: Go through the C++ code shown below and find out the possible output or output from the suggested output (i) to (iv). Also, write the least value and highest value, which can be assigned to the variable Guess.

Аnswer: Possible outputs are (i), (ii) Least value of Guess = 50 Highest value of Guess = 53 Question 23: Go through the C++ code shown below, and find out the possible output or output from the suggested Output Options (i) to (iv) . Also, write the minimum and maximum values, which can be assigned to the variable MyNum.

Аnswer: The possible outputs is (ii) The minimum value of MyNum = 20 The maximum value of MyNum = 24 Question 24: The following code is from game, which generates a set of 4 random numbers. Yallav is playing this game, help him to identify the correct option(s) out of the four choices given below as the possible set of such numbers generated from the program code, so that he wins the game. Justify your answer.

Аnswers: (iv) 19 : 16 : 15 : 16 : Question 25: The following code is from a game, which generates a set of 4 random numbers. Praful is playing this game, help him to identify the correct option(s) out of the four choices given below as the possible set of such numbers generated from the program code, so that he wins the game. Justify your answer.

Аnswer: (iv) 29 : 26 : 25 : 26 : Question 26: Study the following program and select the possible output from it

Аnswers: (i) 103 # 102 # 101 # 100# Question 27: Study the following program and select the possible output from it

Аnswers: (iv) 51 # 50 # Question 28: In the following program, find the correct possible output(s) from the options

Аnswers: (iii) &&&&&&125, **99 (iv) &&&&125, ***99  

Question 1: 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   All India 2017 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:

Question 2: 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.  All India 2015

Question 3: 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.  Delhi 2015

Question 4: Name the header files that shall be needed for successful compilation of the following C++ code  All Indio 2014 C

Question 5: Observe the following C++ code and write the name(s) of the header file(s), which will be essentially required to run it in a C++ compiler.

Question 6: Observe the following C++ code and write the name(s) of the header file(s), which will be essentially required to run it in a C++ compiler.

Question 7: Which C++ 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,

Question 8: Which C++ 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

Question 9: Write the names of the header files, which is/are essentially required to run/execute the following C++ code.

Question 10: Write the names of the header files, which is/are essentially required to run/execute the following C++ code.

Question 11: Which C++ header file(s) will be essentially required to be included to run/execute the following C++ code?

Question 12: Which C++header file(s) will be essentially required to be included to run/execute the following C++ code?

Question 13: Which C++header file(s) will be essentially required to be included to run/execute the following C++ code?

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

Question 15: Look at the following C++ code and find the possible outputs(s) from the options (i) to (iv) following it. Also, .write the maximum values that can be assigned to each of the variables N and M. NOTE • Assume all the required header files are already being included in the code. • The function random(n) generates an integer between 0 and n-1.

Answer: Possible Outputs: (ii) and (iii) Maximum value of N is 2. Minimum value of N is 0. Maximum value of M is 3. Minimum value of M is 0. Question 16: Find and write the output of the following C++ program code:  All India 2016 NOTE  Assume all required header files are already included in the program.

Question 17: Look at the following C++ code and find the possible output(s) from the options (i) to (iv) following it. Also, write the maximum and the minimum values that can he assigned to the variable PICKER.  All India 2016 NOTE  Assume all required header files are already being included in the code. The function random(n) generates an integer between 0 and n -1.

Answer: The possible outputs are (ii) and (iv) Minimum value of PICKER = 1 Maximum value of PICKER = 3 Question 18: Find and write the output of the following C++ program code: Delhi 2016 NOTE Assume all required header files are already included in the program, typedef char STRING [80]; void MIXITNOW(STRING S) { int Size=strlen(S) : for(int I=0; I=’M’ && S[I]<=’U’) S[I]=’@’; } void main( ) { STRING Word = “CRACKAJACK”; MIXITNOW(Word) ; cout<

Question 19: Look at the following C++ code and find the possible output(s) from the options (i) to (iv) following it. Also, write the maximum and the minimum values that can be assigned to the variable CHANGER.  Delhi 2016 NOTE  Assume all the required header files are already being included in the code. The function random(n) generates an integer between 0 and n -1.

(i) FGHI       (ii) BCDEFG          (iii) EFGH       (iv) CDEFG H                                                           H FGHI              BCDEFG                  EFGH               CDEFG H                                                           H FGHI                                                EFGH FGHI                                                EFGH Answer: The possible outputs are (iii) and (iv) Minimum value of Num = 2 Maximum value of NUM = 4 Question 21: Study the following program and select the possible output(s) from the options (i) to (iv) following it. Also, write the maximum and the minimum values that can be assigned to the variable VAL.  All India 2015 NOTE  Assume all required header files are already being included in the program. Random(n) function generates an integer between 0 and n-1. void main() { randomizef); int VAL; VAL=random(3) + 2; char GUESSC] =”ABCDEFGHIJK”; for(int 1=1; K=VAL; I++) { for(int J=VAL; J<=7; J-F-F) cout<

Question 23: Study the following program and select the possible output(s) from the options (i) to (iv) following it. Also, write the maximum and the minimum values that can be assigned to the variable VALUE.  All Indio 2015C NOTE  Assume all required header files are already being included in the program. Random(n) function generates an integer between 0 and n-1.

(i)                             (ii)                               (iii)                                 (iv) ONETWOEND  ONEENDTWO   ONETWOSIXEND      ONETWOSIXEND Answer: The possible outputs are (i) and (iv) Minimum value of VALUE = 2 Maximum value of VALUE = 3 Question 24: Deepa has just started working as a programmer in STAR SOFTWARE company. In the company, she has got her first assignment to be done using a C++ function to find the smallest number out of a given set of numbers stored in a one-dimensional array. But she has committed some logical mistakes while writing the code and is not getting the desired result. Rewrite the correct code underlining the corrections done. Do not add any additional statements in the corrected code. All India 2014C

Question 25: Find output of the following program segment:  All India 2014C

Question 26: Rewrite the following C++ code after removing all the syntax error(s), if present in the code. Make sure that you underline each correction done by you in the code. Important Note: Assume that all the required header file are already included, which are essential to run this code. The correction made by you do not change the logic of the program.

Question 27: Read the following C++ code carefully and find out, which out of the given options (i) to (iv) are the expected correct output(s) of it. Also, write the maximum and minimum value that can be assigned to the variable Start used in the code:

Answer: Correct option is (iv) 20 # 250# Maximum value of variable Start= 3 Minimum value of variable Start = 2 Question 28: What is the difference between call by reference and call by value with respect to memory allocation? Give a suitable example to illustrate using C++ code.  All India 2014 or What is the difference between call by value and call by reference? Also, give a suitable C++ code to illustrate both. All India 2010; Delhi 2009 Answer: Differences between call by value and call by reference are as follows:

The following example illustrates the concept of call by reference:

Question 29: Rewrite the following C++ code after removing all the syntax error(s), if present in the code. Make sure that you underline each correction done by you in the code.  All India 2014 Important Note: Assume that all the required header files are already included, which are essential to run this code. The corrections made by you do not change the logic of the program,

Answer: The corrected code is given below:

Question 30: Read the following C++ code carefully and find out, which out of the given options (i) to (iv) are the expected correct output(s) of it. Also, write the maximum and minimum value that can be assigned to the variable  Taker  used in the code:

(i)  100                               (ii)  50#200# (iii)  100#50#200#        (iv)  100#50  All India 2014 Answer: Correct output for the given code would be option (iii) 100#50#200# Maximum value of Taker = 3 Minimum value of Taker = 2 Question 31: Find syntax error(s), if any, in the following program: (Assuming all desired header file(s) are already included)

Question 32: Based on the following C++ code, find out the expected correct output(s) from the options (i) to (iv). Also, find out the minimum and the maximum value that can be assigned to the variable  Guess  used in the code at the time when value of  Turn  is 3.

Answer: Correct output is (i) 9G0LD*9G0LD*8SILVER* Maximum value of Guess is 2 Minimum value of Guess is 0. Question 33: Based on the following C++ code, find out the expected correct output(s) from the options (i) to (iv). Also, find out the minimum and the maximum value that can be assigned to the variable  Trick  used in the code at the time when value of  Count  is 3

(i)   10EXCEL# 10EXCEL#80K# (ii)  10EXCEL#80K#9GOOD# (iii) 10EXCEL#9GOOD# 10EXCEL# (iv) 10EXCEL# 10GOQD#80K#  Delhi 2013 Answer: Correct output is (iii) 10EXCEL#9GOOD#10EXCEL# Minimum value of Trick is 0 Maximum value of Trick is 2 Question 34: Observe the following program and find out, which output(s) out of (i) to (iv) will not be expected from the program? What will be the minimum and the maximum value assigned to the variable Turn?

(i) 15#22#      (ii) 22#16# (iii) 16#21#    (iv) 2I#22#  Delhi 2012 Answer: (i), (iii) and (iv) can never be the output. Minimum value of Turn =5 Maximum value of Turn =6 Question 35: Observe the following program and find out which output(s) out of (i) to (iv) will not be expected from the program? What will be the minimum and the maximum value assigned to the variable Chance?

(i)  9#6# (ii)  19#17# (iii)  19#16# (iv)  20# 16#  All India 2012 Answer: (i), (ii) and (iv) will not be expected from the program Maximum value of Chance =11 Minimum value of Chance =10 Question 36: Rewrite the following program after removing the syntactical errors (if any). Underline each correction.

Question 37: Rewrite the following program after removing the syntactical errors (if any). Underline each correction.

Question 38: Find the output of the following program;

Question 39: Find the output of the following program

Question 40: Find the output of the following program:

Question 41: Find the output of the following program

Question 42: Find the output of the following program

Question 43: Find the output of the following program

Question 44: Find the output of the following program

Question 45: Find the output of the following program

Question 46: Find the output of the following program

Parameters provided at the time of function calling are called actual parameters. These parameters contain actual values.

Parameters provided at the time of function definition are called formal parameters. These parameters are simple variable declarations, i.e. they do not contain actual values.