0% found this document useful (0 votes)
62 views

Programming Fundamentals Using C++ Question Paper 2014 - Tutorialsduniya

This document contains a question paper for a Fundamentals of Programming exam. It has two parts, with Part I being compulsory and Part II requiring students to attempt 4 of 6 questions. Part I covers topics like binary representation, function output, string comparison, pointer usage, and array traversal. Part II asks students to write functions to compare arrays, describe class static members, explain function overloading vs overriding, count characters in a string, find array element occurrences, and differentiate binary and text files with an example copy constructor.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views

Programming Fundamentals Using C++ Question Paper 2014 - Tutorialsduniya

This document contains a question paper for a Fundamentals of Programming exam. It has two parts, with Part I being compulsory and Part II requiring students to attempt 4 of 6 questions. Part I covers topics like binary representation, function output, string comparison, pointer usage, and array traversal. Part II asks students to write functions to compare arrays, describe class static members, explain function overloading vs overriding, count characters in a string, find array element occurrences, and differentiate binary and text files with an example copy constructor.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Visit https://www.tutorialsduniya.com for Notes, books, programs, question papers with solutions etc.

[This question paper contains 6 printed pages.]

Sr. No. of Question Paper 6065 D Your Roll No ............... .

Unique Paper Code 2341011251305

N arne of the Course B.Sc. (Hons.) Computer Science I B.Sc. (Hons.) Electronics

Name of the Paper Fundamental of Programming

Semester I I III

m
Duration : 3 Hours Maximum Marks: 75

co
Instructions for Candidates

-.

a.
1. Write your Roll No. on the top immediately on receipt of this question paper.

2. There are two parts in the Question Paper.

3. iy
Parts of a Question should be attempted together.
un
4. Part I : All its questions are compulsory.

5. Part II : Attempt any four questions.


lsD

PART I
Question No. 1 is compulsory.
ria

Parts of the question should be attempted together.

1. (a) How.is (-5) 10 represented in 2's complement form using 6 bits? (4)
to

(b) Differentiate between the following : (6)


Tu

(i) Runtime polymorphism and compile time polymorphism

(ii) Call by value and call by reference

(iii) Public and private access type.

(c) Give output of the following code segments :

(i) If x=O, y=O, and z= 1, what are the values of x, y, and z after executing
the following code ? (3)

PT.O.

Visit https://www.tutorialsduniya.com for Notes, books, programs, question papers with solutions etc.

For any query, contact us at [email protected]


Visit https://www.tutorialsduniya.com for Notes, books, programs, question papers with solutions etc.
6065 2

if(z < x II y >= z && z == 1)


if(z && y)
y= 1;
else
x= 1;

(ii) string strl ("DU University"); (4)


string str2 ("DU Union");

m
int result;
result= strl.compare(str2);

co
cout <<result;
result = strl.compare(O, 6, str2); .-"'

a.
cout << result;

(iii) int a=15·int b=9·int c·


' ' ' iy (3)
un
int* p = &b; int* q;
int* r;
q=p;
lsD

r=&c;
p=&a;
*q=8;
ria

*r=*p;
*r=a+*q+*&c;
to

cout <<*p<<" " << *q << " " << *r <<endl;


Tu

(iv) int i; (5)


int list[10] = {2, 1, 2, 4, 1, 2, 0, 2, 1, 2};
int res [ 10];
for(i=O;i< 1O;i++)
res[i]=list[9-i];
for(i=O;i< 1O;i++)
cout <<res[i]<<" ";

Visit https://www.tutorialsduniya.com for Notes, books, programs, question papers with solutions etc.

For any query, contact us at [email protected]


Visit https://www.tutorialsduniya.com for Notes, books, programs, question papers with solutions etc.
6065 3

(d) If four objects of a class are defined, how many copies of class data items
are stored in the memory and how many copies of its functions ? (2)

(e) What are friend functions? What are their advantages? (4)

(f) Find errors in the following code segment : (2)


(i) int main()
{ int i=5;
while(i)

m
{ switch(i)
{

co
default:
case 4:
J case 5:

a.
break;
case 1:

iycase 2:
continue;
un
case 3:
break;
}
lsD

i--·
'
}
}
ria

(ii) #include<iostream> (2)


using namespace std;
to

intmain()
{
Tu

int i = 0;
i=i+1;
cout << i << " ";
/* comment\*//i = i + 1;
cout << i;
}

P.TO.

Visit https://www.tutorialsduniya.com for Notes, books, programs, question papers with solutions etc.

For any query, contact us at [email protected]


------ - - - - - - - - - - - -

Visit https://www.tutorialsduniya.com for Notes, books, programs, question papers with solutions etc.
6065 4

PART II
Attempt any four questions.

2. (a) We have two arrays A and B, each of 10 integers. Write a function that tests
if every element of array A is equal to its corresponding element in arrays
B. In other words, the function must check if A[O] is equal to B[O], A[1] is
equal to B[ 1], and so forth. (5)

(b) What are the static members of a class ? What are the restrictions on static

m
function members ? (5)

co
3. (a) If originally x = 3 andy= 5, what are the values of x andy after evaluation
of each of the following expressions ?

a.
(i) x++ + y

(ii) ++x + 2 iy (4)


un
(b) What do you understand by function overloading ? How is it different from
function overriding? Give an example of function overloading. (6)
lsD

4. (a) Write a C++ program to count occurrences of character 'a' and ' A' in a
given string. (5)
ria

(b) Write a function which returns the number of times an element occurs in an
array. The array and the element to be searched are passed as arguments to
the functions. (5)
to
Tu

5. (a) Differentiate between binary files and text files in C++. (4)

(b) What is copy constructor? Explain with example. (4)

(c) Rewrite the following code fragment using a switch statement: (2)

if(ch == 'E' II ch == 'e')


countE++;

Visit https://www.tutorialsduniya.com for Notes, books, programs, question papers with solutions etc.

For any query, contact us at [email protected]


Visit https://www.tutorialsduniya.com for Notes, books, programs, question papers with solutions etc.
6065 5

elseif(ch =='A' II ch =='a')


countA++;
elseif(ch =='I' II ch == 'i')
count!++;
else
cout << "Error- Not A, E, or I \n";

m
6. (a) Create a class TwoDim which contains x andy coordinates as int. Define the
default constructor, parameterized constructor and void print() to print the

co
co-ordinates. Now reuse this class in ThreeDim adding a new dimension as
z of type int. Define the constructors for the derived class artd override the
method void print() in the subclass. Write main() to show runtime

a.
polymorphism. (8)

iy
(b) Write a C++ statement for the following expression :
un
c = ~a 2 + b 2 - 2ab (2)
lsD

7. (a) Consider the following class definition. What data members and functions
are directly accessible by the functions readit(), inform(), and B(). (3)

void inform(void);
ria

class X
{
int a;
to

float b;
void init(void);
Tu

public:
char ch;
char gett(void);
protected:
double amt;
void getamt(void);
friend void A( void);
};

PT.O.

Visit https://www.tutorialsduniya.com for Notes, books, programs, question papers with solutions etc.

For any query, contact us at [email protected] -__r


Visit https://www.tutorialsduniya.com for Notes, books, programs, question papers with solutions etc.

6065 6
class Y: public X
{
int x;
public:
intj;
void read(void);
protected:

m
void info(void);
friend void B(void);

co
};

a.
(b) Find the error(s) in the following code segment: (2)

class x {............. };
classy {............. };
class z {............. };
iy
un
void alpha() throw(x,y)
{
lsD

throw z();

}
ria

(c) What is the sequence of constructors and destructors being called in a


multilevel inheritance where class A is parent class of class B, class C is
derived class of ~lass B, class D is derived class of class C ? (5)
to
Tu

(1300)

Visit https://www.tutorialsduniya.com for Notes, books, programs, question papers with solutions etc.

I
~.
For any query, contact us at [email protected]
TUTORIALSDUNIYA.COM
Get FREE Compiled Books, Notes, Programs, Question Papers with Solution
etc of the following subjects at https://www.tutorialsduniya.com

 C and C++  Computer System Architecture


 Java  Discrete Structures
 Data Structures  Operating Systems
 Computer Networks  Algorithms
 Android Programming  DataBase Management Systems
 PHP Programming  Software Engineering
 JavaScript  Theory of Computation
 Java Server Pages  Operational Research
 Python  System Programming
 Microprocessor  Data Mining
 Artificial Intelligence  Computer Graphics
 Machine Learning  Data Science

 DU Programs: https://www.tutorialsduniya.com/programs
 TutorialsDuniya App: http://bit.ly/TutorialsDuniyaApp
 C++ Tutorial: https://www.tutorialsduniya.com/cplusplus
 Java Tutorial: https://www.tutorialsduniya.com/java
 JavaScript Tutorial: https://www.tutorialsduniya.com/javascript
 Python Tutorial: https://www.tutorialsduniya.com/python
 Kotlin Tutorial: https://www.tutorialsduniya.com/kotlin
 JSP Tutorial: https://www.tutorialsduniya.com/jsp

You might also like