Archive

Archive for the ‘Computer Science’ Category

Computer Science-1998

Q. 1 (a) Define the following terms : (i) Inheritance (ii) Encapsulation
Ans.1 (a) Inheritance : Inheritance is the process by which one object can acquire the properties of another object. It is the inheritance mechanism that makes it possible for one object to be a specific instance of a more general case.

Encapsulation : Encapsulation is the mechanism that binds together code and data and keeps both safe from outside interference or misuse.

Q. 1 (b) Name the header files, to which the following built-in-functions belong to :
(i) COs() (ii) setw() (iii) toupper() (iv) strcpy()

Ans.1 (b) (i) math.h (ii) iomanip.h (iii) ctype.h (iv) string.h

Q. 1 (c) Find the syntax error(s), if any, in the following program :
include
void main( )
{
int R;W=90;
while W>60
{
R=W-50;
switch(W)
{
20: cout< <"Lower Range"< 30: cout<<"Middle Range"< 40: cout<<"Higher Range"< }
}
}

Ans.1 (c)

Line 1: It should be #include
Line 4: Variables should be seperated using commas. It should be int R,W=90
Line 5: Test expression should be in braces. It should be while(W>60)
Line 10: It should be case 20:
Line 11: It should be case 30:
Line 12: It should be case 40:

Computer Science-1998

Q. 1 (a) Define the following terms : (i) Inheritance (ii) Encapsulation
Ans.1 (a) Inheritance : Inheritance is the process by which one object can acquire the properties of another object. It is the inheritance mechanism that makes it possible for one object to be a specific instance of a more general case.

Encapsulation : Encapsulation is the mechanism that binds together code and data and keeps both safe from outside interference or misuse.

Q. 1 (b) Name the header files, to which the following built-in-functions belong to :
(i) COs() (ii) setw() (iii) toupper() (iv) strcpy()

Ans.1 (b) (i) math.h (ii) iomanip.h (iii) ctype.h (iv) string.h

Q. 1 (c) Find the syntax error(s), if any, in the following program :
include
void main( )
{
int R;W=90;
while W>60
{
R=W-50;
switch(W)
{
20: cout< <"Lower Range"< 30: cout<<"Middle Range"< 40: cout<<"Higher Range"< }
}
}

Ans.1 (c)

Line 1: It should be #include
Line 4: Variables should be seperated using commas. It should be int R,W=90
Line 5: Test expression should be in braces. It should be while(W>60)
Line 10: It should be case 20:
Line 11: It should be case 30:
Line 12: It should be case 40:

Computer Science-1999

Q 1 (a) Why main function is so special. Give two reasons?
Ans. 1(a) Whenever a C++ program is executed only the main() is executed i.e., 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.

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

Ans. 1 (b) (i) string.h (ii) stdio.h (iii) stdio.h (iv) conio.h

Q 1 (c) Find the syntax error(s), if any, in the following program:
#include
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. 1 (c) (i) Line No 5: Undefined symbol ‘i’. The variable ‘i’ is not declared in the program.

(ii)Line No 10: An attempt has been made to assign the value of a pointer to an integer variable.