Sample – Program to enter an integer and output the cube of that integer.

by Nideesh C on February 8, 2011 · 0 comments

in C++




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

Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. Sample – Program to enter a string and find its length.
  2. Sample program (multiplication using addition)
  3. Sample – understanding life time and scope
  4. Sample – understanding scope
  5. Sample – factorial

Leave a Comment

Previous post:

Next post: