Syvum Home Page

Home > Quiz Games > C++ Programming > Print Preview

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.
It then determines the integer's cube and outputs it using the 'cout' command.

8

The cube of 8 is : 512

Index of C++ Programs
 

-
-
 
45 more pages in C++ Programming

Contact Info © 1999-2024 Syvum Technologies Inc. Privacy Policy Disclaimer and Copyright