Computer Science, asked by jagabandhu526, 1 year ago

Write a C++ program to calculate square and cube of an integer number by using inline function.

Answers

Answered by dipayanghosh185
8

Answer:

#include<iostream.h>

#include<conio.h>

#include<math.h>

void main()

{ int num,ans;

clrscr();

cout<<"Enter any Num: ";

cin>>num;

ans=pow(num,0.5);

cout<<"\n Squre of "<<num<<" is: "<<ans; getch();

}

Answered by bilget090
7

Answer:

#include<iostream.h>

#include<conio.h>

class power

{

public:

inline int square(int n)

{

return n*n;

}

inline int cube(int n)

{

return n*n*n;

}

};

void main()

{

int n,r;

power p;

clrscr();

cout<<“\nEnter the Number: \n” ;

cin>>n;

r=p.square(n);

cout<<“\nSquare of “<<n<<” = “<<r<<endl;

r=p.cube(n);

cout<<“\nCube of “<<n<<” = “<<r<<endl;

getch();

}

Explanation:

Similar questions