Important Questions

CBSE Guess > Papers > Important Questions > Class XII > 2010 > Computer Science > Computer Science By MRK

CBSE CLASS XII

1999 Annual Paper

1.a. Why main( ) function is so special. Give two reasons?

Ans. Execution of the program starts and ends at main( ). The main( ) is the driver function of the program. If it is not present in a program, no execution can take place.

1.b. Name the header file of C++ to which following functions belong. (i)strcat( )
(ii) scanf( ) (iii) getchar( ) (iv)clrscr( )

Ans. (i)strcat( ) - string.h
(ii)scanf( ) - stdio.h
(iii)getchar( ) - stdio.h
(iv)clrscr( ) - conio.h

1.c. Find the syntax error(s), if any, in the following program:
#include<iostream.h>
main( )
{ int x[5],*y,z[5];
for(i=0;i<5;i++)
{ x[i]=i;
z[i]=i+3;
y=z;
x=y;
}
}

Ans. (i) Line No 5: Undefined symbol ‘i’. The variable ‘i’ is not declared in the program.
(ii)Line No 10:Assign the value of a pointer to an integer variable. Ie error in x=y.

1.e. Write the output of the following program.
#include<iostream.h>
static int i=100;
void abc( )
{ static int i=8;
cout<<”first =”<<I;
}
main( )
{ static int i=2;
abc( );
cout<<”second =”<<i<<endl;
}

Ans. Output: First =8second =2

1.f. Write a C++ function that converts a 2-digit octal number into binary number and prints the binary equivalent.
#include<iostream.h>
#include<conio.h>
void binary(int a)
//member function for conversion
{ int i,b[5]; //integer array 6
for(i=3;i>=1;i--)
{ b[i]=a%2;
a=a/2;
}
for(i=1;i<=3;i++)
cout<<b[i];
}
void main()
{ int n,x,y;
clrscr( );
cout<<"Enter a two digit octal number: ";
cin>>n;
x=n/10;
y=n%10;
binary(x);
binary(y);
getch( );
}

Paper By Mr. MRK
Email Id : [email protected]@yahoo.com