Monday 14 April 2014

Write A Cpp Program To Implement The Simple Interest Class Design, Name Space, Object Creation


Write A Cpp Program To Implement The Simple Interest Class Design, Name Space, Object Creation


Ex: SIMPLE CLASS DESIGN IN C++, NAME SPACES, OBJECT CREATION

Aim:To write a c ++ program to implement the simple interest class design, name space, object creation

Algorithm:

Step 1: Start the program.
Step 2: Create the class and declare the variable and functions of the class.
Step 3: In main function, objects are created and the respective functions are called for the Function.
Step 4: Get ‘n’ value and calculation function is repeat by using for loop.
Step 5: Stop the program.

Program:

#include
#include
int f1=1,f2=1,f3;
class fib
{
public:
void calculation()
{
f3=f2+f1;
cout<
f1=f2;
f2=f3;
}
};
void main()
{
clrscr();
int n;
fib obj;
cout<<"enter the value of n:";
cin>>n;
for(int i=0;i
{
obj.calculation();
}
getch();
}
Output:

Enter the value of n: 5
2
3
5
8
13

Result:

Thus the implementation of c ++ program for simple class design c ++, name space, object creation is executed and the output has been verified.



0 comments:

Post a Comment