c
Roll No.
S. No. onuestion Paper : 7796
Unique Paper Code : 2341101 ? ' F-l
--- Content provided by FirstRanker.com ---
Name ofthe Paper : Programming F undamentals [,DC-l.1lName of the Course : B.Tec|1. in Computer Science
Semester . : 1
Duration : 3 Hours ' Maximum Marks : 75
(Write your Roll No. on the top immediately on receipt of this question paper.)
--- Content provided by FirstRanker.com ---
There are two parts of the question paper Part I and Part II. Part I has one questionwhich is compulsory. From Paft II attempt any four out of six questions.
Partl ' u
Question No. l is corhpulsbry.
l. (0) Determine which of the following are valid identi?ers. If invalid, state reason : 2
--- Content provided by FirstRanker.com ---
(i) record!(ii) return
(iii) name and address
(iv) ?le?3
P.T.O.
--- Content provided by FirstRanker.com ---
r:7796
( 2 )
(b) If originally x = 3 and y = 5, 2
--- Content provided by FirstRanker.com ---
(i), What is the value bf the expression x++ + ++y ?(ii) What are the values of x and y a?er _the evaluation of the above expression ?
(0) Give the output of the following :
2 ?
(1?) int i] = 123;
--- Content provided by FirstRanker.com ---
?oat f1 = 23.5. f2 = 12.09;J
cout <
cout<
cout<
--- Content provided by FirstRanker.com ---
cout.selt(ios: :right, ios: :adjust?eld);cout<
(ii)
(iii)
( 3 )
--- Content provided by FirstRanker.com ---
int list [6] = {0};for (int i = 0; i < 3; i ++)
list [2*i+l] = i + 2;
for(i=0;i<6;i++)
cout <
- int k = 20:
--- Content provided by FirstRanker.com ---
(k ! = (k = ? ? k)) ? cout << "true"(iv) class A
public:
A()
{cout<<"class A constructor";} .
--- Content provided by FirstRanker.com ---
~A(){ cout <<" class A destructor";}
7796
: cout <<" false";
P.T.O.
--- Content provided by FirstRanker.com ---
( 4 )
class B
public :
B ()
--- Content provided by FirstRanker.com ---
{ cout <<"class B constructor";}~B ( )
{cout<<"class B destructor";}
class C : public B, public A
h
--- Content provided by FirstRanker.com ---
public :C( )
{cout<<"class C constructor";}
~C()
{cout<<"class C destructor";}
--- Content provided by FirstRanker.com ---
int main (){
C
myc;
return 0;
--- Content provided by FirstRanker.com ---
}7796
I l
44?1?71
--- Content provided by FirstRanker.com ---
.??l-T i
1
( 5 ) ? 7796
(d) Give the output of line 1, line 2 and line 3 : 3
--- Content provided by FirstRanker.com ---
class Ap-
int a;
protected:
int b:
--- Content provided by FirstRanker.com ---
public :A () {a = 10; b = 20;}
int c;
void display ()
{ cout <<"Hello Class A";}
--- Content provided by FirstRanker.com ---
class B : public Apublic :
void display ( )
{ cout <<"Hello Class B";}
P.T.O.
--- Content provided by FirstRanker.com ---
P I? r
(e)
(6)
void show ()
--- Content provided by FirstRanker.com ---
Il
cout <cout <}
}:
int main( )
--- Content provided by FirstRanker.com ---
ib, myb;
myb.show( );
myb.display (); //line 3
return 0;
--- Content provided by FirstRanker.com ---
}Write a program thafprints the following pattern
Input to the program is the number of lines.
7796
--- Content provided by FirstRanker.com ---
(f) Change the following do while loop to while loop :(3?)
int x = 0;
do
cout << x ++ <
--- Content provided by FirstRanker.com ---
( 7 )Find the. error in the following function de?nition :
(1')
(ii)
void func (int x, int y)
--- Content provided by FirstRanker.com ---
{.int 2;
return 2;
?pr
obj & operator + (obj?
--- Content provided by FirstRanker.com ---
4l
obj k;
k.val = val + ob.val;
return k; -
--- Content provided by FirstRanker.com ---
~v?ob)
7796
3
I .
--- Content provided by FirstRanker.com ---
a:1
2
P.T.O.
--- Content provided by FirstRanker.com ---
( 8 ) 7796(h) What Would be printed in the following ? 3
(i) bool b;
string 5! ("Hello");
string 52 ("Hcllo!"):
--- Content provided by FirstRanker.com ---
b = (51 = = 32):com <(ii) string 51 ("Hello");
string 52 ("H?llo!");
int i = sl.compare(0,3,52,0.3);
cout<(iii) string 51 ("Good Moming"$:
--- Content provided by FirstRanker.com ---
sl.replace(5, 7, "Evening",0,7);coul<<31 <
(j) What do the following ?le handling keywords do ? Explain each with syntax : 3
ifstream. ofstream, fstream.
--- Content provided by FirstRanker.com ---
( 9 ) 7796Part [I
Attempt any four questions from this part. All questions carry equal marks.
(a) Given a class employee, given the code for the following :
? (1') Create an array of 5 employee objects. 2
--- Content provided by FirstRanker.com ---
(ii) Give the prototype ofnon-member function display to which the array is passed.Function d'isplay returns void. I 2
(b) Input an array A containing 10 integers. Write a function to reverse the elements
of array A so that last element becomes ?rst, second from the last becomes the
second and so on. 4
--- Content provided by FirstRanker.com ---
(c) Write a function called smallest that, given three integers, returns the smallestone. 2
Create a class. fraction containing data members num and deno (num denotes numerator
tmd deno denotes denominator) and appropriate methods mentioned below : 3
(u) A default constructor to accept data members. 2
--- Content provided by FirstRanker.com ---
P.T.O.44 _ _? :9.
( ?0 ) 7796
(b) The copy constructor.
--- Content provided by FirstRanker.com ---
(c') A member function to add two objects of fraction using operator overloading. 34. (u) Create a ?le containing roll no.,_ name, marks in 3 subjects of 5 students. Create
another ?le using this ?le which contains the data of those students whose average
marks >=40. Print the contents of both the ?les. . 5
(/1) Write a program to ?nd the average of n integer numbers. Read the value of n.
--- Content provided by FirstRanker.com ---
If it happens to be zero, throw a user de?ned exception with message ?input error?.Also catch the exception using suitable try and catch block. . 5
5. (u) (i). Write a base class base, with a pure virtual function print. I 2 ?
(ii) Derive a class derived with public inheritance. Override print. 2
,(iii) Overload the print method in the derived class with a single integer parameter
--- Content provided by FirstRanker.com ---
to print the parameter. _ . | l(b) (i) What is run time polymorphism ? How is it achieved ? . 2
(1i) Differentiate between static binding and dynamic binding. ? 3
( ll ) 7796
--- Content provided by FirstRanker.com ---
((1) Explain the difference between pass-by-value and pass-by-reference techniques to passthe data to function. Also givea suitable example of each. 5
(b) Differentiate between gghstents and variables Give example. 3
(c) Write appropriate decla-r'ations for the following : 2
(i) unsigned integer variable : custno
--- Content provided by FirstRanker.com ---
(ii) double precision variable : c = 0333333(U) (1?) Create an array of 12 strings to store the l2 months in a year. 2
(ii) Use string function(s) to create a string that appends the ?rst 3 months. 1
(iii) For the last 4 months search and report the position of substring ?ber? using
string class function.
--- Content provided by FirstRanker.com ---
(b) Determine the value of the following expressions when i=8, j=5, x=0.005, y'?0.01,c=?c? 3
(i) (3*?i ?' 2*j)%(2*? ? i)
(ii) !(c= =99)
(iii) (x>)?)&&(i>0)ll(i<5)
--- Content provided by FirstRanker.com ---
P.T.O.(v A?-?-? A
(C)
7796
--- Content provided by FirstRanker.com ---
( 12) 2 7796'Give the output of the following code : 2
void fun(int& 3, int & b, int c)
{
=a+2;
--- Content provided by FirstRanker.com ---
cout<<"in function a = "<< a <<" b = "<}int main ( )
{
int x;
x = 5;
--- Content provided by FirstRanker.com ---
fun (x, x, x);cOut <<"in main"<
12 _ 2,200