CC-3 Programming Using C++ (1) 2024
CC-3 Programming Using C++ (1) 2024
CC-3 Programming Using C++ (1) 2024
CC-3(R/B)
2024
Programming in C++
Full mark: 60 Time: 3 Hours
No.1 Answer all question (8x1=8)
(a) Which operator pair is used as conditional operator?
(i):: (ii):?
(iii)?: (iv)::*
(b) Which of the following is not a valid keyword?
(i)auto (ii)true
(iii)default (iv)do while
(c) Which of the following operator cannot be overloaded?
(i)== (ii)!
(iii) . (iv) ^
(d) The wrapping of data and functions into a single unit is called:
(i)Abstraction (ii) Encapsulation
(iii)Polymorphism (iv)Data hiding
(e) Which of the following storage classes have zero as its initial value?
(i) Register (ii)External
(iii)Static (iv)Automatic
(f) What will be the output of the following statement?
Cout<<setw(8)<<setfill(‘&’)<<90<<1<<endl;
(i)&&&&&901 (ii)901&&&&&
(iii)&&&&&&&&901 (iv)901&&&&&&&&
(g) A C++ stream is
(i) The flow of control through a function
(ii) a flow of data from one place to another
(iii)associated with a particular class
(iv) a file
(h) Consider the following code:
Class basex
{
Int x;
Public:
Void setx(inty){x=y}
};
Class derived : basex{};
What is the access level for the member function “setx” in the class “derived” above?
(i)protected (ii)private
(iii)local (iv)public
No.2 Answer any eight questions (8x1.5=12)
(a) What is the Inline function?
(b) What is function overloading?
(c) What do you mean by reference variable?
(d) What is a constructor?
(e) What is this pointer?
(f) What is the difference between protected and private member?
(g) What is an abstract class?
(h) Name three stream classes commonly used for file I/O.
1
(i) When do we make a class virtual?
(j) How can you detect the end of file?
No.3 Answer any eight questions (8x2=16)
(a) What is the difference between the actual parameter and the formal parameter ? Also,
give a suitable C++ example.
(b) Find the output of the following program:
#include<iostream.h>
Class Game
{
Public :
Char Magic[20];
Int score;
Game(char m[20], int a)
{
Magic=m; score=a;
}
};
I nt main()
{
Game mg(“Tiger”,500);
Char *Choice;
Choice=mg.Magic;
Choice[4]=’P’;
Choice[2]=’L’;
mg.score +=50;
cout<<mg.Magic<<mg.score<<endl;
Game n=mg;
n.Magic[0]=’A’;
n.Magic[3]=’j’;
n.score=120;
cout<<n.Magic<<n.score<<endl;
return 0;
}
(c) Write a function in C++ to combine the contents of two equal-sized arrays A and B by
adding their corresponding elements as the formula A[i]+B[i]; Where I values range from
0 to N-1 and transfer the resultant content in the third same sized array C.
(d) Explain the dynamic initialization of the variable.
(e) How is polymorphism achieved at compile time and run time?
(f) Describe the syntax of hierarchical inheritance.
(g) Differentiate between ifstream and ofstream class ?
(h) What is a static data member? Write its characteristics.
(i) When does ambiguity arise in multiple inheritance? How can one resolve it?
(j) Find the output of the following program:
#include<iostream.h>
Int main()
{
Int A[]={10,15,20,25,30};
Int *p=A;
While(*p<30)
2
{
If(*p%3==0)
*p=*p+2;
Else
*p=*p+1;
P++;
}
For(int j=0;j<=4;j++)
{
Cout<<A[j]<<”*”;
If(j%3==0)
Cout<<endl;
}
Cout<<A[4]*3<<endl;
Return 0;
}
*******