Program to enter an integer and output the cube of that integer 1 Attachment(s) Program to enter an integer and output the cube of that integer #include #include int cube(int x); //The prototype. void main() { clrscr(); int a; cout << "Enter an integer : "; cin>>a; cout << "The cube of " << a << " is : " << cube(a) << endl; //Call the function cube(a). getch(); } //Defining the function. int cube(int x) { int y; y=x*x*x; return(y); } It then determines the integer's cube and outputs it using the 'cout' command. Sample Input 8 Sample Output The cube of 8 is : 512 |
All times are GMT +5. The time now is 04:33 PM. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.