Introduction To Programming - CS201 Spring 2006 Final Term Paper Session 2
Introduction To Programming - CS201 Spring 2006 Final Term Paper Session 2
com
WWW.VUTUBE.EDU.PK
1
FINALTERM EXAMINATION
SPRING 2006 Marks: 50
CS201 - INTRODUCTION TO PROGRAMMING Time: 120min
(Session - 2 )
StudentID/LoginID: ______________________________
► Iterative function
► Inline function
► Recursive function
► main ()
The reserved words public and private comes under the category
www.vustuff.com
3
► structures
► strings
► accessibility modifiers
► types of functions
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.
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.
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)
{
www.vustuff.com
4
test temp;
temp.x=a+a.t;
temp.b=b+b.t
return(temp);
}
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.
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.