Jumat, 08 Juli 2011

To write a program to find the multiplication values and the cubic values using inline function. July 8, 2011

ALGORITHM:
Step 1: Start the pogram.
Step 2: Declare the class.
Step 3: Declare and define the inline function for multiplication and cube.
Step 4: Declare the class object and variables.
Step 5: Read two values.
Step 6: Call the multiplication and cubic functions using class objects.
Step 7: Return the values.
Step 8: Display.
Step 9: Stop the program.
PROGRAM:
01#include<iostream.h>
02#include<conio.h>
03 
04class line
05{
06   public:
07              inline float mul(float x,float y)
08              {
09                            return(x*y);
10              }
11              inline float cube(float x)
12              {
13                            return(x*x*x);
14              }
15};
16 
17void main()
18{
19              line obj;
20              float val1,val2;
21              clrscr();
22              cout<<"Enter two values:";
23              cin>>val1>>val2;
24              cout<<"\nMultiplication value is:"<<obj.mul(val1,val2);
25              cout<<"\n\nCube value is          :"<<obj.cube(val1)<<"\t"<<obj.cube(val2);
26              getch();
27}

Output:
Enter two values: 5 7
Multiplication Value is: 35
Cube Value is: 25 and 343

Tidak ada komentar:

Posting Komentar