C++ Programming : Program 12-A
Program to enter an integer and output the cube of that integer
#include <iostream.h> #include <conio.h> 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); }
This program takes in an integer a as a screen input from the user.
8
The cube of 8 is : 512
|
45 more pages in C++ Programming