Friday, 22 June 2012

write a c++ program using class to calculate cube and square of a given number using inline function

/*write a c++ program using class to calculate cube and square of a
given number using inline function */
#include<iostream.h>
#include<conio.h>
class calc
{
int no;
public:inline void number()
       {
       int square,cube;
       cout<<"enter the number";
       cin>>no;
       square=no*no;
       cube=no*no*no;
       cout<<"square of a given number is:-"<<square;
       cout<<"\ncube of a given number is:-"<<cube;
       }
       };
int main()
{
calc c;
clrscr();
c.number();
getch();
return 0;
}
/*enter the number5
square of a given number is:-25
cube of a given number is:-125
*/

No comments: