write a c++ prgm to find the cube of given number
#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); } sry i donno c++ so jus copied the code -.-
oh...i want this in simple language
@A.Avinash_Goutham Please provide the link also .. -_-
not by using float
-.- printf("enter the number:"); scanf("%f",&x); x=x*x*x; printf("the cube of number %f",x);
replace %f with %d nd float with int
#include <iostream> using namespace std; int main() { int value, cube; cin >> value; cube = value*value*value; cout << cube; return 0; }
help me to do this in simple manner
@nick67 can u write by giving the values
what do you mean ?
cube = value*value*value; give some value
value is entered with "cin >> value" from the user
return 0; wat is this
At the end of a function (in this case the "main" function) you use a return to exit the function; in this case the value is returned to the program caller, i.e. the O.S. Usually a program without errors returns 0
@nick67 do u have c++ V 3.5
or any version of c++
@nick67
Can u send me that or plzz provide a link to download it ..)))
I use Eclipse with C++ on Linux
u have LINUX.................oh....no i am on WiNDOWS 7
thxxx
for students I strongly suggest to switch to GCC compiler as soon as possible
is this same as Borland C++
@nick67
I don't know, because I don't use Borland anymore, but give a chance to the GNU/Linux world :-)
and as IDE take into consideration Eclipse framework; it's very flexible and let you to do many things http://www.eclipse.org
Join our real-time social learning platform and learn together with your friends!