We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 8
VIDYAA VIKAS HIGHER SECONDARY SCHOOL,
TIRUCHENCODE
Sub : Computer Science (07.08.2017) C++ (2-4) Marks : 150
Class : XII Time : 3 Hrs
I. Choose the Correct Answer : 75 x 1 = 75
1. The basic types are collectively called as____
a) Variables b) Expression c) Tokens d) Looping 2. Which gives special meaning to the language compiler? a) Compiler b) Keywords c) Variable d) Constant 3. Which one of the following is a keyword? a) switch b) Key c) Jump d) Size 4. What is the other name for variable? a) Constant b) Identifier c) Visual d) While 5. What type of numbers starts with 0x or 0X? a) Octal b) Hexadecimal c) Binary d) Decimal 6. Which alphabetic is used to represent the floating point constant in exponent form? a) X or x b) A or a c) F or f d) E or e 7. The special characters like tab, backspace, line feed, null, back slash are called as a) Non-graphic b) Graphic c) String d) Floating 8. Which special character is used to represent the end of string? a) ‘\0’ b) ‘\t’ c) ‘\n’ d) ‘\a’ 9. Which operator requires three operands? a) Unary b) Binary c) Ternary d) Bitwise 10.Which of the following is the Relational operator? a) & b) = = c) < = d) Both b and c 11.Which operators combine the results of one or more condition or variables? a) Relational b) Logical c) Comma d) Additive 12.Which punctuator is used as comments? a) // b) /*— */ c) Both a and b d) + 13.The index value for an array element is indicated within a. { } b) [ ] c) ( ) d) / * 14.The data types such as Array, Function, Pointer, and Reference are called as a) User defined b) Built - in c) Derived d) Integer 15.The function does not return a value is called____ a) Main b) Void c) Static d) Public 16.What is the range for char data type? a) -126 to 127 b) 128 to -127 c) -128 to 127 d) -127 to 128 17.The int data type has the range of values from a) -32767 to 32768 b) - 32768 to 32767 c) 32768 to 32769 d) 32767 to 32768 18.Which variable holds a memory address? a) Double b) Char c) Float d) Pointer 19.Which operator is used for pointer address? a) & b) # c) / d) * 20.The process of changing the data type to another of a variable is called a) Type Cast b) Type float c) Type int d) Type char 21.If int x = 7/3; what is the value stored in x? a) 2.5 b) 2 c) 3 d) 2.0 22.How many methods are there for assigning data to the variables in C++? a) 2 b) 3 c) 4 d) 5 23.The declarations for the object cin are available in header file called as a) instream.h b) istream.h c) stream.h d) iostream.h 24.Which file comprises of all standard declarations and definitions for predefined functions a) header.h b) stream.h c) istream.h d) iostream.h 25.The header file can have a preprocessor directive of____ a) # b) $ c) / d) % 26.Which statement is used to select between two alternatives? a) if-else b) if c) for d) while 27.Which has branches for multiple alternatives, depending on the value of a single variable? a) if b) switch c) for d) while 28.Which statement is used to exit from switch statement? a) break b) continue c) switch d) case 29.Which executes a set of instructions repeatedly for a certain number of times? a) loop b) if c) if-then d) switch 30.How many kinds of loops are there in C++? a)1b) 2 c) 3 d) 4 31.Which is called as exit-check loop? a) do-while b) while c) for d) if 32.Which condition is called as the entry - check loop? a) while b) break c) for d) do 33.Which statement forces the next iteration and skips any code and continues is in the loop body? a) continue b) break c) switch d) Nested - if 34.A loop embedded within another loop is called____ a) Nested b) Link c) break d) continue 35.What are called as the building blocks of C++? a) Functions b) if – else c) for d) switch 36.Which statement is at the end of the function and transfers control, after call statement? a) return b) go to c) continue d) break 37.Which is used to check the data requirement of the function in the system? a) Compiler b) Interpreter c) Linker d) Object 38.In which method any change in the formal parameters is not reflected back to the actual parameter? a) call by value b) call by reference c) call d) return 39.In which method, the called function arguments - formal parameters become alias to the actual? a) call by value b) return c) call by reference d) call 40.In which method any change made in the formal parameter is reflected back in the actual parameter? a) call by value b) call by reference c) return d) void 41.Switch expression should be evaluated only through a) string b) integer c) array d) float 42. Which are the channels, data flows from call statement to function and vice versa? a) Parameters b) Function c) Return d) go to 43. How many times the following loop will be executed? for(int i=1;i<6;i++) a) 1 b) 5 c) 6 d) 7 Read the following C++ program carefully and answer the questions from 44 to 48: # include<iostream.h> void main() { int num = 2; do { cout<<num*num<<’\t’; num+=1; } while (num<6); } 44.Name the control variable used in the program? a) num b) += 1 c) \t d) none of these 45.What is the test expression (condition) used? a) num b) num * num c) (num<6) d) none 46.How many times will the loop be executed? a) 6 b) 4 c) 5 d) 3 47.What is the output of the following program? a) 2 4 9 16 25 b) 2 4 6 8 c) 4 9 16 25 d) 0 4 9 25 48.Which type of loop statement is used in the program? a) entry check loop b) exit check loop c) entry controlled loop d) selection loop 49.What is the error thrown by the compiler for the following snippet? if (a>b); cout<<”Greater”; else cout<<”Lesser”; a) Misplaced if b) Misplaced else c) Misplaced if..else d) Misplaced else…if 50.What is the output of the following snippet? int a=20,b=10; if(a>b) cout<<a; else cout<<b; a) 20 b) 10 c) error d) infinite 51.What is the output of the following program? void main() { int i=6; loop_start: { i=i+1; if(i<6) goto loop_start; } cout<<i; } a) 6 b) 7 c) error d) infinite 52. The statement int A;b; is invalid because a) Only one variable should be given b) Capital A is not allowed c) Variables should be separated by comma d) All of these 53. What will be the output? # include<iostream.h> void main() { int i=10; do { cout<<i; i--; }while(i<=5); getch(); } a) 54321 b) -32768 c) -32767 d) infinite 54. What will be the output? int rank=2; switch(rank) { case 1 to 2 : cout<<’\n’<<”Best rank”; break; case 3 to 4 : cout<<’\n’<<”Good rank”; } a)Best rank b) Error c) Good rank d) Both a & c 55.What is the impact of the following statements? int sum=0; for(int ctr=1;ctr<5;ctr++); sum+=ctr; cout<<sum; The output will be _____________ a) 15 b) 16 c) 5 d) error 56.Declaration of a function in C++ is made through a) function call b) passing parameters c) function prototype d) argument 57.The calling function parameters are called ______. a) formal parameters b) actual parameters c) dummy parameters d) duplicate parameters 58.Which of the following reduces the size of the program? a) keywords b) variables c) tokens d) functions 59.Which of the following is used to separate a set of actual parameter function? a) , (comma) b) ; (semi-colon) c) . (dot) d) & (and) 60.A preprocessor directive starts with the symbol _____________ a) # b) ++ and -- c) && and | | d) > and < 61. A program written in high level language is called __________ a) object code b) source code c) executable code d) all of these 62.Which of the following functions will be executed first automatically when a C++ program is executed? a) void b) main() c) recursive d) call by reference 63.Which of the following is the invalid variable declaration? a) int a,b; b) int a; int b; c) int a; float b; d) int a; b; 64.Machine readable form of a program is called ___ a) source code b) object file c) compiler d) executable file 65.Statement used in C++ to display message and result is a) print b) println c) cout d) cin 66.Basic statements in C++ are constructed using a) variables b) tokens c) constants d) operators 67.What will be the value of the expression (a+b-c)/5*2<(a%10) where a=99,b=20,c=10? a) 1 b) 23.2 c) 0 d) 9 68.Find out the value assigned to m, where n1=7,n2=8; m=(n1>n2)?n1:n2; a) 7 b) 8 c) False d) True 69.What is the value of z? float f=8.5; int z=f; a) 5 b) 8 c) 9 d) error 70.What is the assigned to x? float x; int a=7,b=3; x=a/(float)b; a) 2.0 b) 2.333333 c) 2.5 d) error 71.If a=5 and b=4, the value of the expression a+b/2*6 is a) 15 b) 16 c) 17 d) 18 72.What is the value in c when the following snippet is executed? int a,b,c; a=8; b=3; c=a/b; c=++c; cout<<c; a) 1 b) 2 c) 3 d) 4 73. Which statement is at the end of the function and transfers control, after call statement? a) return b) go to c) continue d) break 74.Which is used to check the data requirement of the function in the system? a) Compiler b) Interpreter c) Linker d) Object 75.Which is the actual parameter of the segment? # include<iostream.h> # include<conio.h> int sum(int x, int y) { return(a+b); } void main() { int a,b; int add=0; add=sum(a,b); cout<<add; } a) a,b b) x,y c) x,y,a,b d) add,sum II. Answer the following Questions : (Any 20) 20 x 2 = 40 76.How are the pointer variables declared? 77.Determine the order of evaluation of the expr. (i)(b*b)-4*a*c (ii)a+pow(b,c)*2 78.What will be values stored in the variables of the following snippts? fun=1; sim=2; final=--fun+ ++sim-fun; sim= _______ fun=________ final=________ 79.What is the use of value at operator(*)? 80.Write the output of the following expressions a)10>20 b)500.45<=1005 c)99!99.5 d)9==9 81.How will you evaluate the expressions x+y*z<e/f? 82.Evaluate the following c++ expressions Assume a=5,b=3,d=1.5,c is integer and f is float a) c=d*a+b b)x=a++ *d +a; 83.What is the purpose of continue statement? 84.What are the control statements? What are the two main categories of control structures? 85.Write the rules for the formation of nested loops. 86. Define loop. 87.Write the difference between cin and cout. 88.Write short notes on break statement. 89.Write appropriate if construct for the following task : Set grade to ‘A’, if marks are above 90, otherwise set grade to ‘B’ 90. What is the impact of the following statements ? int sum = 0; for(ctr = 1; ctr < 5; ctr++); sum += ctr; cout << sum; 91. What is function? 92.Write the advantages of functions. 93.Categorise the following declaration as valid/invalid, if valid specify the reasons a)char name(10); b)float f,int; 94.What will be the output of the following program? #include<iostream.h> #include<conio.h> void main() { int i=1,sum=0; clrscr(); while(++i<=5) { cout<<’\n’<<i; sum+=i;} cout<<’\n’<<i<<’\t’<<sum; getch(); } 95.Write the general syntax and example of a function prototype. 96.Define control structures. 97.Write the general working process of loops. 98.Define. Source Code, Object Code 99.Write the C++ equivalent expressions using the conditional operator. Where 1. f = 0.5 if x = 30, otherwise f = 5 2. f n = 0.9 if x >= 60, otherwise .7 100. Define control structures. III. Answer the following questions : (Any 7): 7 x 5 = 35 101. Explain about entry-check loop. 102. Explain about Nested…if statement. 103. Explain about exit check loop. 104. Explain about switch statement. 105. Explain about Call by reference. 106. Explain about Call by value. 107. Discuss about the general working of for loop. 108. Explain if and switch statement. 109. Write the output for the following program. i) #include<iostream.h> #include<conio.h> void main() { int num = 1784, s= 0, d = 0, x; x = num; clrscr(); for(;num > 0;) { d = num % 10; s += d; num = num / 10; } cout << “\nThe sum of digits of “ << x << “is : “<< s; getch(); } ii) #include<iostream.h> #include<conio.h> first(int i) { return i++;} second(int x) { return x--;} void main( ) { int val=50; val=val*val/val; val=second(val); val=first(val); cout<<”\n val:”<<val; }
110. Write the output for following program :
i) # include <iostream.h> # include <conio.h> void main() { clrscr(); for(int i = 1,s = 0; ; i++) { if (i%2 == 0) continue; s += i; if ( i > 9) break; } cout << “\nThe sum is ....” <<s; getch(); } ii. # include <iostream.h> # include <conio.h> void main() { int i = 1, sum = 0; clrscr(); while(++i <= 5) { cout << ‘\n’ << i; sum += i; } cout << ‘\n’ << i << ‘\t’ << sum; getch(); }