BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan

BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan (http://bzupages.com/)
-   Object Oriented Programming (http://bzupages.com/300-object-oriented-programming/)
-   -   Program to enter an integer and output the cube of that integer (http://bzupages.com/f300/program-enter-integer-output-cube-integer-14560/)

bonfire 01-03-2011 02:53 PM

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);
}
This program takes in an integer a as a screen input from the user.
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.