ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I would ignore everyone's corrections to the code you posted, if you just copied it from the book. If you're just starting to learn and you're reading a good book, just learn from the book and afterwards worry about changing things. Don't start changing things instantly while you're just learning, it will just cause you to branch your thoughts off in twenty directions at once instead of just paying close attention to the book and learning from it.
But make sure that "end" is "endl" and prefixed with std::
as was suggested.
EDIT:
Also, I'm sure that as the book progresses it will clean things up a little more, it's just starting off that way.
Last edited by pr_deltoid; 09-03-2010 at 02:29 AM.
Well Just an update. I wrote my own version of a multiplier. Cheap and cheesy but moving along.
Code:
// This is a mathmatical program for simple multiplication.
#include <iostream>
// Receiving a and b and turning a into firstNumber and b into secondNumber.
int mulTiply (int firstNumber, int secondNumber)
{
using std::cout;
using std::endl;
// announcing to the user of the status of the equation
cout << endl;
cout << "First Number " << firstNumber << " and second number " << secondNumber << " Now being multiplied.\n";
cout << endl;
cout << "Please Wait....";
cout << "Now Returning your value\n";
cout << endl;
// Returning firstNumber(a) and secondNumber(b) back to main for output.
return (firstNumber * secondNumber);
}
int main()
{
using std::cout;
using std::cin;
using std::endl;
// Opening statement asking user what he would like to multiplied.
cout << "Type your two numbers to be multiplied.\n";
cout << "It must only include the numbers on each line.\n";
// a = number
// b = number
// c = output
int a, b, c;
cout << endl;
cout << "First Number: ";
cin >> a;
cout << "Second Number: ";
cin >> b;
// calling Function Add for addition and return.
c = mulTiply(a,b);
// multiply function return the value of c.
// Announcing to the user the = of c
cout << a << " * " << b << " = " << c << endl;
cout << "Thank you for choosing JC Multiplication Program!\n";
return 0;
}
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.