View Single Post
  #1  
Old 01-03-2011, 02:53 PM
bonfire's Avatar
bonfire bonfire is offline
M.Arsalan Qureshi

 
Join Date: Oct 2008
Location: Garden Town, Multan Cantt
Posts: 616
Program / Discipline: BSTS
Class Roll Number: 09-31
bonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond repute
Default Program to enter an integer and output the cube of that integer

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.
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

__________________

Reply With Quote