Roll No.
S. No. of Question Paper : 7796
--- Content provided by FirstRanker.com ---
Unique Paper Code : 2341101 F-1
Name of the Paper : Programming Fundamentals [DC-1.1]
Name of the Course : B.Tech. in Computer Science
Semester : 1
Duration : 3 Hours Maximum Marks : 75
--- Content provided by FirstRanker.com ---
(Write your Roll No. on the top immediately on receipt of this question paper.)
There are two parts of the question paper Part I and Part II. Part I has one question which is compulsory. From Part II attempt any four out of six questions.
Part I
Question No. 1 is compulsory.
- (a) Determine which of the following are valid identifiers. If invalid, state reason : 2
- recordl
- return
- name and address
- file-3
--- Content provided by FirstRanker.com ---
- (b) If originally x = 3 and y = 5, 2
- What is the value of the expression x++ + ++y ?
- What are the values of x and y after the evaluation of the above expression ?
--- Content provided by FirstRanker.com ---
- (c) Give the output of the following : 2
- int il = 123;
float fl = 23.5, f2 = 12.09;
cout <cout.setf(ios: :fixed, ios: :floatfield); --- Content provided by FirstRanker.com ---
cout<cout.setf(ios: :left, ios: :adjustfield;
cout<cout<<"%";
cout.setf(ios: :right, ios: :adjustfield);
cout<
- int il = 123;
- (ii) int list [6] = {0}; 3
for (int i = 0; i < 3; i++)
list [2*i+1] = i + 2;
for (i = 0; i < 6; i ++)
cout <- (iii) int k = 20; 2
--- Content provided by FirstRanker.com ---
(k != (k = - k)) ? cout << "true" : cout <<"false"; - (iv) class A 3
{
public:
A()--- Content provided by FirstRanker.com ---
{cout<<"class A constructor";}.
~A()
{ cout <<" class A destructor";}
}; - class B
--- Content provided by FirstRanker.com ---
{
};
public:
B()
{ cout <<"class B constructor";}--- Content provided by FirstRanker.com ---
~B()
{cout<<"class B destructor";}
class C: public B, public A
{
};--- 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;
} - (d) Give the output of line 1, line 2 and line 3 : 3
class A
{
int a;
};--- Content provided by FirstRanker.com ---
protected:
int b;
public:
A () {a = 10; b = 20;}
int c;--- Content provided by FirstRanker.com ---
void display ()
{ cout <<"Hello Class A";}
class B: public A
{
public:--- Content provided by FirstRanker.com ---
void display ()
{ cout <<"Hello Class B";} - void show ()
{
cout < cout < }--- Content provided by FirstRanker.com ---
};
int main()
{
b myb;
myb.show();--- Content provided by FirstRanker.com ---
myb.display(); //line 3
return 0;
} - (e) Write a program that prints the following pattern : 3
*--- Content provided by FirstRanker.com ---
* *
* * *
* * * *
* * * * *
Input to the program is the number of lines. - (f) Change the following do while loop to while loop : 3
int x = 0;
do
{
cout << x ++ <} while (x < 100); - (g) Find the error in the following function definition : 1
- void func (int x, int y)
{
int z;
return z;
}. - obj & operator + (obj. ob) 2
{
objk;
k.val = val + ob.val;
return k;--- Content provided by FirstRanker.com ---
}
--- Content provided by FirstRanker.com ---
- void func (int x, int y)
- (h) What would be printed in the following ? 3
- bool b;
string s1 ("Hello");
string s2 ("Hello!");--- Content provided by FirstRanker.com ---
b = (sl == s2);
cout <- string sl ("Hello");
string s2 ("Hello!");
int i = firstranker.compare(0,3,s2,0,3);
cout<- string s1 ("Good Morning");
--- Content provided by FirstRanker.com ---
s1.replace(5, 7, "Evening",0,7);
cout< - string sl ("Hello");
- bool b;
- (i) What is the role of the generic exception handler, catch(....). Give an example. 3
- (j) What do the following file handling keywords do ? Explain each with syntax : 3
ifstream, ofstream, fstream.
--- Content provided by FirstRanker.com ---
--- Content provided by FirstRanker.com ---
--- Content provided by FirstRanker.com ---
--- Content provided by FirstRanker.com ---
- (iii) int k = 20; 2
--- Content provided by FirstRanker.com ---
Part II
--- Content provided by FirstRanker.com ---
Attempt any four questions from this part. All questions carry equal marks.
- (a) Given a class employee, given the code for the following :
- Create an array of 5 employee objects. 2
- Give the prototype of non-member function display to which the array is passed. 2
Function display returns void.
- (b) Input an array A containing 10 integers. Write a function to reverse the elements of array A so that last element becomes first, second from the last becomes the second and so on. 4
- (c) Write a function called smallest that, given three integers, returns the smallest one. 2
- Create a class fraction containing data members num and deno (num denotes numerator and deno denotes denominator) and appropriate methods mentioned below : 3
- A default constructor to accept data members. 2
- (b) The copy constructor. 2
- (c) A member function to add two objects of fraction using operator overloading. 3
- (a) Create a file containing roll no., name, marks in 3 subjects of 5 students. Create another file using this file which contains the data of those students whose average marks >=40. Print the contents of both the files. 5
- (b) Write a program to find the average of n integer numbers. Read the value of n.
If n happens to be zero, throw a user defined exception with message "input error".
Also catch the exception using suitable try and catch block. 5 - (a)
- Write a base class base, with a pure virtual function print. 2
- Derive a class derived with public inheritance. Override print. 2
- Overload the print method in the derived class with a single integer parameter to print the parameter. 1
- (b)
- What is run time polymorphism? How is it achieved ? 2
- Differentiate between static binding and dynamic binding. 3
--- Content provided by FirstRanker.com ---
- (a) Explain the difference between pass-by-value and pass-by-reference techniques to pass the data to function. Also give a suitable example of each. 5
- (b) Differentiate between constants and variables. Give example. 3
- (c) Write appropriate declarations for the following : 2
- unsigned integer variable: custno
- double precision variable: c = 0.3333333
--- Content provided by FirstRanker.com ---
- (a)
- Create an array of 12 strings to store the 12 months in a year. 2
- Use string function(s) to create a string that appends the first 3 months. 1
- For the last 4 months search and report the position of substring "ber" using string class function. 2
--- 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
- (3*i - 2*j)%(2*j - i)
- !(c==99)
- (x>y)&&(i>0)||(j<5)
- (c) Give the output of the following code : 2
void fun(int& a, int & b, int c)
{
b=a+2;
cout<<"in function a = "<< a <<" b = "< }--- Content provided by FirstRanker.com ---
int main ()
{
int x;
X = 5;
fun (x, x, x);--- Content provided by FirstRanker.com ---
cout <<"in main"<return 0;
}
--- Content provided by FirstRanker.com ---
--- Content provided by FirstRanker.com ---
--- Content provided by FirstRanker.com ---
--- Content provided by FirstRanker.com ---
--- Content provided by FirstRanker.com ---
This download link is referred from the post: DU B-Tech Last 10 Years 2010-2020 Previous Question Papers (University of Delhi)