C+ Paper 24
C+ Paper 24
]
Your Roll No...
G
Sr. No. of Question Paper : 906
2342571101
Unique Paper Code
Name of the Paper Programming Fundamentals Using C++
Semester
Maximum Marks :90
Duration:3 Hours
1. Write your Roll No. on the top immediately on receipt of this question paper.
2 Section A is compulsory.
3. Attempt any four questions from Section B Parts of a question must be answered
together.
Section A
1. (a) Differentiate between while and do..while loop giving suitable example for
each. (3)
(b) Assume the memory address of variable a is 400 and an integer variable is
of size 4 bytes. Write the output that will be produced on the execution of
the following code segment: (3)
int a = 7;
int *c = &a;
cout<<c<<endl:
cout<<c+1<<"\t"<<c+2<<"\t"<<endl;
PTO.
906 2
(c) Write the output that will be produced on the execution of the following
code segment: (3)
return (x + y+ z + w);
int main()
(d) What is void pointer? What is the use of having void pointers? (3)
() List the different visibility modes used for declaring data members and member
functions in a class? (3)
(h) Write the output of the following code segment assuming address of x is
2000 and address of p is 3000: (3)
int x = 2;
int *p:
p = &X;
cout << *p;
*p = 4;
cout << p;
cout << * (&x)i
906 3
(i) For the following stalements state whether they are true or false: (3)
Section B
2. (a) What are the different types of inheritance? Give suitable diagrams depicting
each. (5)
(ü) If the input arguments are integers the function returns their sum. Else,
if the arguments are strings it returns a string formed by concatenating
the two input strings. (5)
(c) State whether the following statements are true or false: (5)
PT.O.
906
3. (a) Identify the error in the following program. Write the corrected code. (5)
#include <iostream>
Using namespace std;
class Room
int main ()
(c) Write a program to swap two values using function template . (5)
4. (a) Write the output produced on the execution of the following C++ statements:
(5)
i)cout<<(30!=25) ?10:20;
ii) cout<<5589;
ii) cout<<(56<=100) ||( 10>20&&5>=5) ;
iv) cout<<8+9*21-10/5;
v) x=5; y=xtti
cout<<0==0?x:y ;
5
906
screen taking
display the following pattern on the
(b) Write a C++ code to (5)
number of lines as input from the user.
BA
CBA
DCBA
using (5)
(c) What is the difference between opening a file
() constructor function
Data members
2. accountNumber
3. typeOfAccount
4. balanceAmount
PI.0.
906 6
Member functions
void mna in ()
int num[ ]={80,55,20,35,99)}
int *ptr;
ptr = num;
cout <<"\nValue of ptr :
ptr++; "<<*ptr << "\n";
cout<<"\nValue of ptrt+
ptr--: :
"<<*ptr << "\n";
cout<<"\nValue of ptr--: "<<*ptr <« "\n";
ptr+=3;
cout<<"\nValue of ptr+3: "<<*ptr << "\n";
ptr=ptr-1;
cout <<\nValue of ptr-l: "<<*ptr << "\n";
906 7
A Consider the following class definition.
(5)
class One
public:
static int X;
class A {...);
class B: public A{...);
class C: public B{... ;
class D: public B, public A{..:
Filel":
7. (a) Write a program to write the following statements in the file" (5)
following
(b) Write the output that will be produced on the execution of the
(5)
code segment:
i)
for (int i-l; i<4; i++)
P.T.0.
906 8
ii)
void increment ( )
static int i
cout<< i <<endl;
i = i + 1
int main( )
{
increment ( );
increment ( );
increment ( );