Term Ii Examination : 2014 -15

Total Page:16

File Type:pdf, Size:1020Kb

Term Ii Examination : 2014 -15

TERM II EXAMINATION : 2014 -15 COMPUTER SCIENCE (Code 083) Class : XI SET – B Max. Marks : 70 Date : 3-12-2014 Duration : 3 hrs. General Instructions: (i) All questions are compulsory (ii) Programming Language: C++

I. 1 Illustrate the use of local and global variable with a suitable C++ code 2 2. Rewrite and underline the corrections after removing the syntactical errors in the given program segment. # include int Marks 5 ; void main() { Total = 70 ; for ( int G = 1; G = < 5 ; G++ ) 2 if ( Total % Marks = 0 ) cout << Marks * Total ; else cout << Marks + Total <

4 What values will be assigned to the variables A, B , C and D after the execution of the following program segment

int A = 0, B=0, C=0, D=0, L =0; while ( L < = 5 ) { switch ( ++L) { case 1 : case 2 : ++A; case 3 : case 4 : ++ B; case 5 : ++C; default : ++ D; } } cout << “ A = “ << A << “ “ << “ B = “ << B <

5. Write the output of the following program 3 int A = 3 ; void Show ( int X , int Y , int &Z) { A + = X + Y; Z = A + Y ; Y + = X ; cout << X << “ ,” << Y << “ ,” << Z <

6. Nita is playing a game that generates a set of 4 random numbers. Help her to identify the correct option(s) from the option given below so that she wins the game . Justify your answer. page 1 of 4

#include #include int Low = 15 ; void main ( ) { randomize(); 2 int POINT = 5 , Number; for ( int L = 1; L <=4 ; L++ ) { Number = Low + random ( POINT); cout << Number << “ : “ ; POINT -- ; } } i) 19 : 16 : 15 : 18: ii) 14 : 18 : 15 : 16: iii) 19 : 16 : 14 : 18: iv) 19 : 16 : 15 : 16:

II. 1 .What is the difference between function definition and function prototype 2

2. Rewrite the following if-else statement with switch - case statement char code; if ( code == ‘P’ ) cout << “ Principal \n”; else if ( code == ‘T’) cout << “ Teacher \n”; else if ( code == ‘C’ || code == ‘G’) 3 cout << “Grade - IV Staff \n”; else if ( code == ‘O’) cout << “Office Assistant\n”; else cout << “ Student \n”; 3. Write the output of the program segment given 2 int R = 50 , P = 3; do { R = 100 ; cout << R << “ \t “ << P << “\n”; R ++ ; P -- ; } while ( P > = 1);

4 . Write a program to check if the entered element is an alphabet , digit , vowel or some other symbol 3

5. Illustrate the use of any two jump statements in C++ with suitable examples 2

III 1. What is the difference between function call by value and function call by reference give any suitable C++ code to illustrate both 2 2 Write the output of the following segment 2 int TEST ( int & X , int Y = 100 ) { if ( X % Y = =0 ) return ++X ; else return Y - - ; } void main ( ) { int G = 10 , S= 20 ; S = TEST ( G , S ) ; G = TEST( S ) ; cout << G << " " << S <

3. Write a user defined function in C++ to print the sum of the digits of a Number which are divisible by 2 or are divisible by 3 . Number is passed as an argument to the function and the function returning the sum of the digits 3 4. Write the Looping Statements which will produce the following Output 2 C D E F G C D E F C D E C D C 5. Give the output of the program segment int Y = 75 ; cout << -- Y << Y << Y-- << Y ; 1

6. Write a User defined function to find the smallest of three numbers 2

IV 1. What is the difference between int G and int G[20] 1

2. Find the output of the following code snippet. void main() { int R[ ] = { 12 , 8 , 7 , 6 , 1 , 5 , 4 , 2 , 3 , 8 , 5 , 60 , 12 } ; 2 int Q = 65 ; for ( int j = 0 ; j < 10 ; j + +) if ( R [ j ] % 2 ! = 0 ) Q= Q + R [ j ]; cout << “ Q = “ << Q << endl ; }

3. The address of an element stored at location B [50] is 2500 and the address of the element stored at B [70] is 2660. Calculate the Base Address ,and also the size of each element which it occupies in the memory. 2

4. What is recursive function in C++ ? Illustrate using suitable C++ code 3

V. 1. Write a user defined function sumseries() to find the sum of the series 1 + 1/2! + 1/4! + 1/6! + 1/8! + ...... upto N terms 3

2. What do you mean by the Base address of an array . give example 1

3 Write a user defined function to find the sum of the factorial of the digits of any given number The function has to accept the (number as long type ) and return the sum . 4

4. Write a user defined function to accept a number and check if it a palindrome number or not . The function has to return value 0 if it is palindrome number else 1. 4

VI 1 . The array contains the following elements given as int C [15] = { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120 ,130,140,150 }; Write function in C++ to add 20 to all the elements which are divisible by 3 and add -15 to other elements of the array 2

2. Define a function Reversearray ( int [ ] , int ) , that would accept a one dimensional integer array Numbers and its size N. The function should reverse the array without using any second 3 array

3. Write a user defined function to search for an element in array . The Function has to take the array , its size and the element to be searched as parameters . The function has to return value 1 if the search is successful else -1 if is not successful. 3

4. Write a user defined function to find the largest element in an array containing integers 3

5. Write a function to rearrange the array , If the array initially contains the following elements 3 int B [ ] = { 3, 7, 15 , 84 , 11 , 20 , 4 , 33 , 19 } then after rearranging the array should contain

int B [ ] = { 20 , 4, 33, 19 , 11 , 3 , 7, 15 , 84 }  Note The function should not use any other array

Page 4 of 4

Recommended publications