Vous êtes sur la page 1sur 3

MM: 70 No 1

FLORETS INTERNATIONAL SCHOOL, PANKI, KANPUR Computer Science (083)- CLASS XI Questions

Time: 3Hrs. Marks

a. Distinguish between (give example): (i) (ii) b. Convert : Formal parameter, Actual parameter, Value Parameter & Variable parameter. Defining a variable & Declaring a variable. (i) 4A7C16 to Binary (ii) C2F16 to octal 2+2 1+1

2 a. Evaluate the following, where a, b, c are integers and d, f are floating point numbers. The value of a=8, b=4 and d=2.5 (i) f = a * b + a/b (ii) c = d + a + b % a b. What will be the size of following constants? \v, \v c. Write the corresponding C++ expressions for the following mathematical expressions: i) (ii) 2

1 2

3. a. What do you understand by the terms Encapsulation, polymorphism, Abstraction? b. What is the difference between Global Variable and Actual Variable? Give an example in C++ to illustrate both. c. What is difference between a and a in C++? d. Name header file, to which following functions belong: isalpha(), gotoxy(), strlen( ), getc() 4. Give the output of following programs (assuming all required header files are included) a.
int bug (int x) { return x++; } int error(int y) { return ++y; } void main(void) { int val=50; val = bug(error(val *=val/val)); cout << "val= "<<val<<endl;

3 2 1 2

b.

void T(int &a, int &b, int c) { cout <<a <<' '<<b<<' '<<c<<endl; a=b+c; b+=a+c; cout <<a <<' '<<b<<' '<<c<<endl; } void main(void) { int x = 5; T(x,x,x++); cout <<x <<endl; }

3+4

c.

void X(int & A, int B ) { A = A + B; B = A B; A = A B; } void main ( ) { int a = 4, b = 18; X(a,b); cout << a << , << b <<end1; } divide(int a) { return (a++ * val); } void main(void) { int val = 16; val = divide(val= val/4); cout <<"\nval "<<val<<endl; int a = -10; int go(int &y) { a = a+1; return (a * y++); void main(void) { int a = 5,c1; c1 = go (go (a)); cout << '\n'<<c1<<endl; Also give the output if we replace c1 = go (go (a)); with c1 = go(a) + go(a)

d.

void main() { cout<< 14%3<<endl; cout<< -14%3<<endl; cout<< 14%-3<<endl; int val =2;

2+3
}

e.

f.

void main ( ) { int x = 5, y = 5; cout << x++ ; cout << \t ; cout << --x ; cout << \t ; cout << y++ << \t << --y <<\n; }

2+2

g.

h. void Encrypt(char T[])


}

{ for (int i=0;T[i]!='\0';i+=2) if (T[i]=='A' || T[i]=='E') T[i]='#'; else if (islower(T[i])) T[i]=toupper(T[i]); else T[i]='@'; } void main() { char Text[]="SaVE EArtH"; //The two words in the string Text //are separated by single space Encrypt(Text); cout<<Text<<endl; }

4+3

5. a. Find syntax error(s), if any, in the following program: 3

include <iostream.h> void main ( ) ; { int x ; cin << x ; for ( int y=0 ; y<x ; y++) { int z = y ;} cout << z <<endl ; }
b. Let S is a compound statement, & E1, E2, E3 are expressions then what is the difference between the given two program fragments a) & b) a). for(E1; E2; E3) b). E1; S; while (E2) { S; E3; } 2

6. Consider the following program & answer the following questions:

void strfunc(char str[]) { int i, j, len = strlen(str) ; for(i=0; i<len; i++) { for(j=0; j<=i; j++) cout <<str[j]; cout <<endl; } } void main(void) { strfunc(Delhi) ; }
a. Name header files required to execute the given program correctly. b. Give the output of the given program. c. Re-write user-defined function strfunc without using built-in function strlen: 2 2 3

7. a. Write a C++ function newpower(X,Y) to replaces the built-in function pow(X,Y). Also write the main() function that gets values of X & Y from the user, to test this newpower function. b. WAP to enter a +ve integer & create a new number by arranging the digits of original number in ascending order and then display both numbers along with their difference. 4

HINT: Store the digits in an array & sort it. Pass the array to a separate function for sorting. For e.g: INPUT: 31498 OUTPUT: Number entered = 31498 New number is = 13489 Difference = 18009
c. Write a function MERGE () to receive & merge the contents of 2 sorted arrays A[5] & B[7] into 3rd array C[12]. Assuming array A Is sorted in ascending order, B is sorted in descending order, the resultant Array C is required to be in ascending order.
int a,e,s; cin>>a >>e; s = (e==1)? (a>28 && a<35) ? 480:(a>35)? 600: 300: (e==0)? 200: 0; cout<< s<<endl;

d. Rewrite the given segment using nested if statement:

Vous aimerez peut-être aussi