You are on page 1of 30

www.vujannat.ning.

com

CS201 Introduction to Programming


Final Term Examination - February 2005
Time Allowed: 150 Minutes

Please read the following instructions carefully before attempting any of the
uestions:

1. Attempt all questions. Marks are written adjacent to each question.


2. Do not ask any questions about the contents of this examination from
anyone.
a. If you think that there is something wrong with any of the questions,
attempt it to the best of your understanding.
b. If you believe that some essential piece of information is missing,
make an appropriate assumption and use it to solve the problem.
c. Write all steps, missing steps may lead to deduction of marks.
d. All coding questions should be answered using the C ++ syntax.
You are allowed to use the Dev-C++ compiler to write and test your code. If you do
so please remember to copy and paste your code into the examination solution area.
(Do NOT share your code; your colleague could get higher marks than you!!)

**WARNING: Please note that Virtual University takes serious note of


unfair means. Anyone found involved in cheating will get an `F` grade in
this course.

Total Marks: 100 Total


Questions: 13

Question No. 1 Marks : 2

A function declaration has the same relationship to a function definition that

1 a class definition has to an object definition


2 an object declaration has to an object
3 a variable has to a variable declaration
4 a variable declaration has to the variable itself
5 they have no relationship

Question No. 2 Marks : 12


Write a function to overload subtraction operator for Class Order, which you created in
previous question. The class has following attributes/ data members
i) OrderID
ii) Items
iii) PricesOfItems

Write the main () to call the - operator and print the result also. This operator should subtract
the items of one object from the other.

Question No. 3 Marks : 4

What is the difference between an array and a structure?

Question No. 4 Marks : 2

When we write a class template the first line must be:

1 template < class class_type>


2 template < class data_type>
3 template < class T >, Here T can be replaced with any name but it is preferable.
4 class class-name()
5 class template<class_name>

Question No. 5 Marks : 2

A friend function of a class has access

1 To all data member and functions of the class


2 Only to other friend functions of the class
3 Only to private data of the class
4 Only to public data of the class
5 To private data declared in main()

Question No. 6 Marks : 5

Briefly describe the role of each of the following within a class:

1. Instance variables
2. Instance methods
3. Constructors

Question No. 7 Marks : 20

Create a class named Order. This class has the following attributes/ data members
i) OrderID
ii) Items
iii) PricesOfItems
a) Create the object of this class using parameterized constructor in order to initialize
OrderID and Items data members. Default values of both the data members must be
equal to 1.
b) Write the following member functions of this class;
i) OrderBill ( ), this function will calculate the invoice of an order and display the
result. The formula to calculate the invoice is
invoice=SumPrices();

ii) SumPrices( ), this function will sum the prices of the items entered by the user
from
keyboard in PricesOfItems array and returns the result.

c) Write the setter functions for OrderID, Items, and PricesOfItems. And getter functions
for OrderID and Items.

Also write the main () to create the object of class Order.

Question No. 8 Marks : 2

The new operator

1 is used to declare objects or variables


2 can not create and initialize an object
3 names an object or variable
4 returns an address to an object or variable
5 can allocate an appropriate amount of memory for an object or variable

Question No. 9 Marks : 15

Write a program that inputs one string of max length of 10. If the string is identical to "Virtual",
output the message "Correct Password"; otherwise, output the first four characters in the
message and the length of the message.

Question No. 10 Marks : 2

If we open a file stream myfile for reading, what will give us the current position of the file
pointer?

1 tellg()
2 tellp()
3 seekg()
4 seekp()
5 fstream.h

Question No. 11 Marks : 2

There is a class Student, Which one of the following is a valid destructor for this class.

1 Student();
2 Student(int);
3 ~ Student();
4 int~ Student();
5 ~ Student(int);

Question No. 12 Marks : 5

What is a friend function? Explain with example?

Question No. 13 Marks : 6

Write code that will declare, initialize, and fill in an array of objects of type int. After your code
executes, the array should look as follows.

0 2 4 6 8 10 12 14 16 18
www.vujannat.ning.com

CS201 Introduction to Programming


Final Term Examination – Spring 2005
Time Allowed: 150 Minutes

Please read the following instructions carefully before


attempting any of the questions:
1. Attempt all questions. Marks are written adjacent to each
question.
2. Do not ask any questions about the contents of this
examination from anyone.
a. If you think that there is something wrong with any of
the questions, attempt it to the best of your understanding.
b. If you believe that some essential piece of information is
missing, make an appropriate assumption and use it to
solve the problem.
c. Write all steps, missing steps may lead to deduction of
marks.
d. All coding questions should be answered using the C ++
syntax.
You are allowed to use the Dev-C++ compiler to write and test your
code. If you do so please remember to copy and paste your code into
the examination solution area. (Do NOT share your code; your
colleague could get higher marks than you!!)

**WARNING: Please note that Virtual University takes serious


note of unfair means. Anyone found involved in cheating will
get an `F` grade in this course.

Total Marks: 70 Total Questions: 10

Question No. 1 Marks : 02

A friend function
o must be having a prototype with no arguments
o must be invoked by the class that declares it a friend
o must be invoked by an object of the class that declares it a friend
o can access the private data of the class that declares it a friend
o cannot access the data members of a class

Question No. 2 Marks : 02

Which one of the following operators is a unary operator?

o OR ( || )
o AND ( &&)
o XOR ( ^ )
o Complement operator ( ~ )
o Insertion operator (>>)

Question No. 3 Marks : 10

Write a program that uses a function multiple(int,int) that determines for a pair
of integers whether the second integer is a multiple of the first. The function
should take two integer arguments and return 1 (true) if the second is a multiple
of the first and 0 (false) otherwise. Use this function in a program that inputs a
series of pairs of integers.

Question No. 4 Marks : 02

The new operator


o is used to declare objects or variables
o can not create and initialize an object
o names an object or variable
o returns an address to an object or variable
o can allocate an appropriate amount of memory for an object or
variable

Question No. 5 Marks : 08

Write a program that uses a function template called min to determine the
smaller of two arguments. Test the program using integer, character and floating
point number pairs in main ().

Question No. 6 Marks : 20

Create a class named Account, its data members are


i. Account NO
ii. Account Title
iii. Balance
a) Create the object of this class using parameterized constructor in order to
initialize all the three data members i.e. Account NO. Account Title. Balance

b) Write a member function of this class named deposit (), this function will
calculate the current balance for the user's account. In deposit function user will
be prompted to enter the amount to be deposited and displays the incremented
balance.

c) Write an other member function of this class named addToFile(), In this


function write the values of the data members Account NO, Account Title and
Balance in the file named Account.txt.

Also write the getter and setter functions for the data members of this class

Question No. 7 Marks : 02

If the statements
int j,k;
j = 123;
k= 234;
int* q, * r;
cout<<*q<<' '<<*r;
are executed, what will be displayed?

o The values of j and k


o The addresses of q and r
o The addresses of j and k
o 132 , 234
o garbage values

Question No. 8 Marks : 15

Write a class Rectangle that performs the mathematical operations (Subtraction


and Multiplication) on its height and width with the help of operator overloading.

Class Rectangle should have the following Private data members

1. height
2. width
a) Write a parameterized constructor to initialize the data members.
b) Write member functions to Overload the following Operators and Display
the Results.
1. –
2. *
Implement the following checks in operator overloading functions:
i. Check for negative values in subtraction before and after the operation,
change them into absolute values or negate them. (If width = -3 its
absolute value is width=3.)
ii. Check for zero values in multiplication. If any value is zero, displays a
message" Height or width cannot be zero". And exit from the function.
In main () create the objects of the class and assign values to their data
members and then call the overloaded operators

Question No. 9 Marks : 02

A copy constructor
o takes no arguments
o copies the data of any two constructors in that class
o takes an arbitrary number of arguments
o creates a new object that later may be assigned the data of an
existing object
o creates an object initialized with the same data as an existing object

Question No. 10 Marks : 07

Write the statements that will


a) declare a one-dimensional integer array with 8 elements

b) initialize each element in the array to 0

c) prompt the user for 8 integers and store those integers in the array

d) find the largest value in the array (use a loop)


http://vujannat.ning.com
BEST SITE TO HELP STUDENTS
FINALTERM EXAMINATION
SPRING 2006 Marks: 50
CS201 - INTRODUCTION TO PROGRAMMING Time: 120min
(Session - 3 )

StudentID/LoginID: ______________________________

Student Name: ______________________________

Center Name/Code: ______________________________

Exam Date: Wednesday, August 23, 2006

Please read the following instructions carefully before attempting any


of the questions:
1. Attempt all questions. Marks are written adjacent to each question.
2. Do not ask any questions about the contents of this examination
from anyone.
a. If you think that there is something wrong with any of the
questions, attempt it to the best of your understanding.
b. If you believe that some essential piece of information is
missing, make an appropriate assumption and use it to solve the
problem.
c. Write all steps, missing steps may lead to deduction of marks.
d. All coding questions should be answered using the C ++ syntax.
You are allowed to use the Dev-C++ compiler to write and test your code. If
you do so please remember to copy and paste your code into the examination
solution area. (Do NOT share your code; your colleague could get higher
marks than you!!)

**WARNING: Please note that Virtual University takes serious note of


unfair means. Anyone found involved in cheating will get an `F` grade
in this course.

For Teacher's use only


Question 1 2 3 4 5 6 7 8 9 Total
Marks

Question No: 1 ( Marks: 2 ) - Please choose one


To access the 8th element of an int array named myArray of 15 elements, you would
write

► int[8]

► int[7]

► myArray[8]

► myArray[7]

Question No: 2 ( Marks: 2 ) - Please choose one

A friend function of a class has access

► To all data member and functions of the class

► Only to other friend functions of the class

► Only to private data of the class

► Only to public data of the class

Question No: 3 ( Marks: 2 ) - Please choose one

A copy constructor is always called when

► an object is initialized with another object data of the same class when it’s
created

► an object is initialized with another object of any class when it’s created

► an object is initialized with a variable of a basic type when it’s created

► an object is not initialized when it’s created

Question No: 4 ( Marks: 2 ) - Please choose one

Consider the function below:


template <class T>
T abc (U x)
{
return (-x);
}
We call this function as
cout << abc(-9.6) << endl;

The answer will be:

► 9.6
► -9.6

► 9

► -9

Question No: 5 ( Marks: 6 )

Calculate the following bitwise operations.


a) 01001000 & 10111000 =

b) 01001000 | 10111000 =

c) 01110010 ^ 10101010 =

Question No: 6 ( Marks: 10 )

Write a program that will create a class stat. the class stat has the following data
members.
A float array values of size 10.
The variables sum and avg both of type float.
The class stat has the following member functions.
takedata()
calculate()
show()
The function takedata() is used to read data from the user through keyboard into the
array values. The function calculate() is used to calculate the sum of all values in the
array values and store the value in the variable sum. The function calculate(), then
calculates the average by using the formula sum/10 and stores the result in the variable
avg. The function show() is used to display the value in avg on the screen.
The program will create an object obj1 in the class stat. The program will read data into
obj1 using takedata(), calculate the average using the function calculate() and then
display the result using show() function.

Question No: 7 ( Marks: 10 )

Write a program that will create a class rectangle. The class rectangle has the data
members width and height, both of type float. The class rectangle has one member
function getdata(). The program will create two objects rect1 and rect2 of the class
rectangle. The program will read data into rect1 and rect2 trough the function getdata().
The program will compare both the objects by overloading “==” operator to decide that
rect1 and rect2 are same or not.
If rect1 and rect2 are same then program will display the message “Both rectangles are
same” otherwise the program will display “Both rectangles are not same”.

Note: rectangles are called same if their heights and widths are same.

Question No: 8 ( Marks: 8 )


Write a program that will calculate the volume of a sphere using function templates.
The function name is volumecal(). Two arguments (i.e. radius and a constant pi) are
passed to the function volumecal(). After calculating the volume the, the function
volumecal() display the result on the screen.
The formula for volume of sphere is
volume= (4/3) * pi * (radius)3

Where pi= π=3.141569

Question No: 9 ( Marks: 8 )

We have two classes Class1 and Class2 and we want to construct two way friendships
between them. Write the coding sketch to achieve this friendship.
www.vujannat.ning.com

CS201 Introduction to Programming


Mid Term Examination – Spring 2006
Time Allowed: 90 Minutes

Please read the following instructions carefully before


attempting any of the questions:
1. Attempt all questions. Marks are written adjacent to each
question.
2. Do not ask any questions about the contents of this
examination from anyone.
a. If you think that there is something wrong with any of the
questions, attempt it to the best of your understanding.
b. If you believe that some essential piece of information is
missing, make an appropriate assumption and use it to solve
the problem.
c. Write all steps, missing steps may lead to deduction of
marks.
d. All coding questions should be answered using the C ++
syntax.
You are allowed to use the Dev-C++ compiler to write and test
your code. If you do so please remember to copy and paste your
code into the examination solution area. (Do NOT share your
code; your colleague could get higher marks than you!!)

**WARNING: Please note that Virtual University takes serious note of


unfair means. Anyone found involved in cheating will get an `F` grade in
this course.

Question No. 1 Marks : 10

Write the function definitions for the following:


a) A function test() that would take three integer values x, y and z (as
parameters), find the largest and return the result to the calling function.
b) A function sum() that would take the one integer array myArray[ ] of size 10
(as parameter), calculate the sum of the elements of myArray[ ] and display
the result.
Note: The function sum() returns no value.

Question No. 2 Marks : 6

Write a program that will create and display the following series:
65, 44, 27, 14, 5, 0, -1, 2, 9, 20.
Hint:
The series is created by the formula 2x2 – 3x
for x=-5 to 4
The variable x is of type integer.

Question No. 3 Marks : 2

The value of 2*15/3*7+3*2 is

 146
 76
 8
 70
Question No. 4 Marks : 2

Carefully analyze the following lines of code and chose the correct option.
ch1=”a”;
ch2=’a’;

 ch1 and ch2 are strings


 ch1 is string and ch2 is character
 ch2 is string and ch1 is character
 ch1 and ch2 are characters

Question No. 5 Marks : 2

The size of a double variable is

 2 bytes
 4 bytes
 8 bytes
 10 bytes
Question No. 6 Marks : 2

An array is also called

 an array variable
 array declaration
 struct
 constant pointer

Question No. 7 Marks : 10

What will be the output of the following programs?


a) Program1

#include <iostream>
int main()
{
unsigned short x = 1;

for (int i = 0; i < 10; i++)


{
cout << x << endl;
x = x << 1;
}

return 0;
}
b) Program2

#include <iostream.h>
int main()
{
unsigned short x = 1024;

while(x>=1)
{
cout <<x << endl;
x =x >> 1;
}

return 0;
}
Question No. 8 Marks : 6

Calculate the following expressions for


x=3 and y=2
1) ++x++*++y
2) 3*++x+--y
3) ++x*4*++y
WWW.vujannat.ning.com
http://vujannat.ning.com
Largest Online Community of VU Students

MIDTERM EXAMINATION
SPRING 2007 Marks: 50
CS201 - INTRODUCTION TO PROGRAMMING Time: 90min
(Session - 1 )

StudentID/LoginID: ______________________________

Student Name: ______________________________

Center Name/Code: ______________________________

Exam Date: Saturday, May 12, 2007

Please read the following instructions carefully before attempting any


of the questions:
1. Attempt all questions. Marks are written adjacent to each question.
2. Do not ask any questions about the contents of this examination
from anyone.
a. If you think that there is something wrong with any of the
questions, attempt it to the best of your understanding.
b. If you believe that some essential piece of information is
missing, make an appropriate assumption and use it to solve the
problem.
c. Write all steps, missing steps may lead to deduction of marks.
d. All coding questions should be answered using the Dev-C++/C ++
syntax.
e. Choose the most appropriate choice (among the given) while answering
the MCQs.

You are not allowed to use any compiler or IDE.

**WARNING: Please note that Virtual University takes serious note of


unfair means. Anyone found involved in cheating will get an `F` grade
in this course.
For Teacher's use only
Question 1 2 3 4 5 6 7 8 9 10 Total
Marks
Question 11 12 13 14
Marks

Question No: 1 ( Marks: 1 ) - Please choose one

Analysis is the -------------- step in designing a program

► Last

► Middle

► Post Design

► First

Question No: 2 ( Marks: 1 ) - Please choose one

The remainder (%) operator is,


An arithmetic operator

► A logical operator

► A relational operator

► A division operator

Question No: 3 ( Marks: 1 ) - Please choose one

When a call to function statement is encountered,

► The control is transfer to its Prototype

► The control is transfer to its definition


► The compiler stop execution of whole program

► The program hangs

Question No: 4 ( Marks: 1 ) - Please choose one

In C/C++ language when an array is passed to a function then by default its passing
Mechanism is,

► Call by value

► It depends on type of array

► Call by Reference

► It depends on the return type of function.

Question No: 5 ( Marks: 1 ) - Please choose one

Computer can do,

► More than what we tell it

► Less then what we tell it

► Like human being

► Exactly what we tell it

Question No: 6 ( Marks: 1 ) - Please choose one

int x = 2 * 3 + 4 * 5;
What value will x contain in the sample code above?

► 22
► 26

► 46

► 50

Question No: 7 ( Marks: 1 ) - Please choose one

In flow chart process is represented by

► Rectangle

► Arrow symbol

► Oval

► Circle

Question No: 8 ( Marks: 1 ) - Please choose one

Which one of the following will declare a pointer to an integer at address 0x22ff74 in memory?

► int *x;
*x = 0x22ff74;

► int *x = &0x22ff74;

► int *x = *0x22ff74;

► int *x( &0x22ff740 );

Question No: 9 ( Marks: 1 ) - Please choose one


When we are using const keyword with a variable x then initializing it at the time of declaration is

► Must

► Optional

► Not necessary

► A syntax error

Question No: 10 ( Marks: 1 ) - Please choose one

int numarray[4][4] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};


What value does numarray [0][3] in the sample code above contain?

► 3

► 5

► 7

► 4

Question No: 11 ( Marks: 5 )

Write Header files for the functions,

i. sqrt();
ii. getline();
iii. printf();
iv. exit();
v. rand();

Question No: 12 ( Marks: 5 )

Write down the output of the following code?


int array[7], sum = 0;
for(int i=0;i<7;i++)
{
array[i] = i;
sum+= array[i];
}
cout<< “ Sum = “ <<sum;

Question No: 13 ( Marks: 15 )

Write a program which consists of three variables Area, Per, Base, this program should find
and display the area of triangle using the formula,

Area = (Base * Per)/2 ;


Take the value of variables Per and Base from the user.

Question No: 14 ( Marks: 15 )

Write a function BalerAvg which calculate and display the average of a player (Baler), call this
function in main program (function). Take input of runs given and ball delivered from the user in
main funciton.
The average may be calculated by the formula,

Average = (Total Runs given * 60) / (Total number of balls delivered);


Connecting VU Students
FINALTERM EXAMINATION
SPRING 2006 Marks: 50
CS201 - INTRODUCTION TO PROGRAMMING Time: 120min
(Session - 1 )

StudentID/LoginID: ______________________________

Student Name: ______________________________

Center Name/Code: ______________________________

Exam Date: Wednesday, August 23, 2006

Please read the following instructions carefully before attempting any


of the questions:
1. Attempt all questions. Marks are written adjacent to each question.
2. Do not ask any questions about the contents of this examination
from anyone.
a. If you think that there is something wrong with any of the
questions, attempt it to the best of your understanding.
b. If you believe that some essential piece of information is
missing, make an appropriate assumption and use it to solve the
problem.
c. Write all steps, missing steps may lead to deduction of marks.
d. All coding questions should be answered using the C ++ syntax.
You are allowed to use the Dev-C++ compiler to write and test your code. If
you do so please remember to copy and paste your code into the examination
solution area. (Do NOT share your code; your colleague could get higher
marks than you!!)

**WARNING: Please note that Virtual University takes serious note of


unfair means. Anyone found involved in cheating will get an `F` grade
in this course.

For Teacher's use only


Question 1 2 3 4 5 6 7 8 9 Total
Connecting VU Students
Marks

Question No: 1 ( Marks: 2 ) - Please choose one

A for loop usually consist of __________ expressions.

► 1

► 3

► 2

► 4

Question No: 2 ( Marks: 2 ) - Please choose one

A preprocessor directive is identified by _________ symbol

► #

► {

► (

► ~

Question No: 3 ( Marks: 2 ) - Please choose one

Which of the following operators can not be overloaded?

► new

► delete

► +=

► sizeof

Question No: 4 ( Marks: 2 ) - Please choose one


Connecting VU Students
Analyze the following code
class myclass
{
private:
float x,y;
public:
void myclass(float a, float b)
{
x=a;
y=b;
}
void diplay()
{
cout<<endl<<x<<endl<<y;
}
};

What is wrong with the above code?

► The member functions should be private

► constructor must not have a return type

► The constructor should have no body

► There is no error in the given code

Question No: 5 ( Marks: 6 )

Analyze the following code and list all the errors and line numbers in the given code.
int i=2;
for(i<=100;i++)
{
if(i%2==0)
{
cout<<i;
cout<<” is even /n’;
}
}

Question No: 6 ( Marks: 7 )

Declare a class student having the following data members and member functions in the
Connecting VU Students
class.
stdno(integer)
stdname(character array of size 20)
phone(long integer)

getdata() function that will read data into members data.


Display() function that will display the data on the screen.

Question No: 7 ( Marks: 6 )

a. Write the statement that will create an array of 10 objects of the class student and
place the base address of the array in a pointer ptr of the class student given in Question
No. 6.
b. Write the code of the parameterized constructor for the class student given in
Question No. 6.

Question No: 8 ( Marks: 15 )

Write a program that will create a class distance. The class distance consist of two data
members feet and inches, both of types float. The class distance consist of two member
functions, getdata() and show(). The function getdata() is used to read data from the
user through keyboard into feet and inches. The show() function is used to display the
values of feet and inches on the screen.
The program will create two objects dest1 and dest2 of the class distance. The program
will read data into dest1 and dest2 using getdata(). The program will create another
object dest3 of the class distance by overloading the minus “-“operator trough
expression dest3=dest1-dest2. The program will then display dist3 on the screen using
show() function. The program also takes care of the fact that distance can not be
negative. If dest2 is larger then dest1 then dest3 should not be created and program
should display the message “Distance can not be negative”.

Question No: 9 ( Marks: 8 )

What are the benefits of the templates?


Connecting VU Students
1
FINALTERM EXAMINATION
SPRING 2006 Marks: 50
CS201 - INTRODUCTION TO PROGRAMMING Time: 120min
(Session - 2 )

StudentID/LoginID: ______________________________

Student Name: ______________________________

Center Name/Code: ______________________________

Exam Date: Wednesday, August 23, 2006

Please read the following instructions carefully before attempting any


of the questions:
1. Attempt all questions. Marks are written adjacent to each question.
2. Do not ask any questions about the contents of this examination
from anyone.
a. If you think that there is something wrong with any of the
questions, attempt it to the best of your understanding.
b. If you believe that some essential piece of information is
missing, make an appropriate assumption and use it to solve the
problem.
c. Write all steps, missing steps may lead to deduction of marks.
d. All coding questions should be answered using the C ++ syntax.
You are allowed to use the Dev-C++ compiler to write and test your code. If
you do so please remember to copy and paste your code into the examination
solution area. (Do NOT share your code; your colleague could get higher
marks than you!!)

**WARNING: Please note that Virtual University takes serious note of


unfair means. Anyone found involved in cheating will get an `F` grade
in this course.

For Teacher's use only


Question 1 2 3 4 5 6 7 8 9 Total
Connecting VU Students
2
Marks

Question No: 1 ( Marks: 2 ) - Please choose one

. A function that calls itself is known as

► Iterative function

► Inline function

► Recursive function

► main ()

Question No: 2 ( Marks: 2 ) - Please choose one

The function call to a default constructor

► looks like any function call, except there is no return value

► never takes any arguments

► creates but cannot initialize an object

► is made automatically when an object is created

Question No: 3 ( Marks: 2 ) - Please choose one

Static member functions

► must be declared inside the class definition, but defined outside it

► must be declared private

► have multiple copies for the entire class

► can access only static data

Question No: 4 ( Marks: 2 ) - Please choose one

The reserved words public and private comes under the category
Connecting VU Students
3
► structures

► strings

► accessibility modifiers

► types of functions

Question No: 5 ( Marks: 6 )

Write a program that will read any four digit number from the user through key board and st
number into an Integer variable n. The program then calculates the sum of all the digits in t
number n and display the result on the screen.

Question No: 6 ( Marks: 10 )

Write a program that will create a class book. The class book has the following data
members
bookid( long integer)
author( char array of size 20)
yearpb( integer)
The class book has a parameterized constructor and a member function
show() that is used to display the data in a tabular form. The program creates three
objects b1, b2 and b3 and assigned data trough the parameterized constructor. The
program then display the using the show() function.

Question No: 7 ( Marks: 8 )

Analyze the following code and list all the errors along the line numbers.
class test
{
private:
int a, b;
public:
test( int x, int y)a(x),b(y){};
void show()
{
cout<<endl<<a<<endl<<b;
}
test operator +(test t);
}
test operator+(test t)
{
Connecting VU Students
4

test temp;
temp.x=a+a.t;
temp.b=b+b.t
return(temp);
}

Question No: 8 ( Marks: 10 )

Is it possible to define a two dimensional array of objects in a class? If yes justify your
answer by giving an example program. If no then give reasons.

Question No: 9 ( Marks: 8 )

Write a program that uses a function template divide(). The function divide() will take two
values and return the reminder of these two values. Test the function with two integer
values x=104 and y=49 and two float vales a=6.9 and b=2.7.

You might also like