Jump to content
357mag

Earlier version of C++ Builder program

Recommended Posts

Here is one of my projects which was written in an earlier version of C++ Builder. You will notice that I'm using #include<conio.h> plus I'm using getch();

// This program demonstrates writing a simple function to cube a number

#include <iostream>
#include <conio.h>

using namespace std;

int cube(int y); // function prototype

int main()
{
	int x;

	cout << "Enter an integer value: ";
	cin >> x;

	int answer = cube(x); // call the cube function and pass x as an argument and assign result to the variable answer

	cout << "That number cubed is " << answer << endl; // print the result

	getch();
	return 0;
}

int cube(int y) // function definition
{
	return y * y * y;
}

 

Share this post


Link to post

And, the point of this post is... what, exactly? I don't see a question or problem stated.
 

However, why were you ever mixing C's <conio.h> with C++'s <iostream> in the first place? Get rid of <conio.h>, you don't need it. Use std::cin.get() instead of getch().

Edited by Remy Lebeau

Share this post


Link to post
1 hour ago, 357mag said:

Someone asked to see the code. So I post the code.

Imagine we are starting at the beginning of this post. What are we to make of what is in this page alone? 

Share this post


Link to post
2 hours ago, 357mag said:

Someone asked to see the code. So I post the code.

Then you should have posted the code as a reply to that earlier discussion. Instead, you posted it as a new discussion with no context. At least add a link to the original discussion. 

Edited by Remy Lebeau

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×