Sunday 13 November 2011

c++(cpp) cplusplus examples with questions

Learn  object oriented programming language with given questions and develop the logic.
a) What will be the output of following program
class a {
a()
{ cout«" 1" ; ) ~a( ) I cout « M 2 "; ( class b : a
i
b( )
{ cout « " 3"; ) ~b( )
{ coul « " 4    )
)
void main ( ) I
b obj ; I
b) Is new better than malloc ( ) ? Justify your answer.



c) Explain Ihe output of the following :
class mca
(
public : int a; private : int b; protected : int c ;
};
void main( ) I
mca obj 1;
cout « obj I.a «obj l.b « obj l.c;
}

d) Explain output :
main ( ) {
char s [ ] = "man" ; inl t ;
for(i = 0;s[i];i++)
cout «\ n« s[i] «* (s + i) «* (i + s) « i[s] ; )

e) # include < iostream.h>
void main ( )
{
inl n = 5. fact = 1 ; while (n >1) fact * = n - -;
cout « \ n « factorial value < < \ n « fact ; 1
0 Explain bool dala type in C++.



2.a) What is Object Oriented Programming ? Explain features of OOP in detail. , b) What is Class Templates 7 Explain its uses in detail.

3. a) Write a program to design a class for addition of two objects using friend
function.
b) Write a C++ program to design a class 'String' and overload operator + for concatenation of two strings.
4. What constructor and Destructor ? Write a program to demonstrate invocation of
Constructor and Destructor in multiple inheritance.
| 5.a) What is Run Time Type Information (RTTI) 7 Explain with suitable example, b) Write a C++ program illustrating NAMESPACE for addition of 2x2 matrix.
6. Define a class date with suitable constructor method. Write a member function to swap two dale objects. Write a function to validate the date.

7.a) What is library function < cmath > ? Explain with a C++ program for sqrt.
b) What is relational operator 7 Write a C++ program illustrating equal to (= =) operator.
5. Write a program in C++ that consist of two classes time 12 and time 24. The first
one maintains lime on 12-hour basis whereas the other one maintains it on 24-
hour basis. Provide conversion functions to carry out the conversions from object
of one type to another.
OR
There are UK) records present in a file. Each record containing 6-character Ilem_Codi\ 20-character ltvm_Namc and an Integer Quantity. Write a program in C++ to read these records arrange them in the ascending order and write them in the same file overwriting the earlier records.

Share This
Previous Post
Next Post

FYJC XI standard online admisson Process and declaraton of Merit list . Cut off List For prevous year also . 10 Th Results onlne declaraton Maharashtra Region .

0 comments: