#include<iostream.h>
#include<conio.h>
void main()
{
clrscr(); //to clear screen
float cube(float); //function prototype
float a,cu;
cout<<“Enter any number:”;
cin>>a;
cu=cube(a); //function calling
cout<<“nCube of “<<a<<” is “<<cu;
getch();
}
float cube(float a)
{
float cu;
cu=a*a*a;
return(cu);
}
can we use int here instead of float……..
yes, but keyword must int.
sir run nhi ho raha
@ankur ya you can use int instead of float…….
but int did’nt show after decimal
#include
#include
int i=0;
int Cube(int n){
if (i==3){
return 1;
}
else {
i++;
return n*Cube(n);
}
}
int main()
{ int n,cube;
printf(“Please enter the number!\n”);
scanf(“%d”,&n);
cube=Cube(n);
printf(“\nThe cube if %d is %d”,n,cube);
return 0;
}
I don’t get it.😵😵😵
what would happen if i wrote the function prototype outside the main?
#include
#include
Void main()
{
Int a,cube;
Clrscr();
Cout<>a;
Cube=a*a*a=a3;
Cout<<"the cube of number is"<<cube<<endl;
Getch();
}
#include
#include
inline int cube(int a)
{
return(a*a*a*);
}
void main()
{
clrscr();
int x,y;
cout<>x;
y=cube(x);
cout<<"the cube of number="<<y;
getch();
}
create c++ program to find the cube of a number using inline function. take data and display C++ program to find reverse of a number using class create function outside the class function should also be inline
Get the cube of 3 using function