Zmodem commented on a Page, C++ variable use  -  Sep 15, 2008

Just like to toss in my two cents, so bear with me.

A major contradiction in programming is using meaningful variable names, which, in this case, make no sense at all. Why not use names like: num1, num2 & product? Anyways, I'm using Visual Studio 2008 and when I compile this code, I always get a product response of:

The two you entered multiplied is 0

No matter what numbers I've entered, the product is always 0. The reason for this is quite obvious, as everyone has already stated that your variables are all mixed up and in the wrong spot. In any case, something to the correct deter would be:

#include <iostream>
using namespace std;

int main()
{
  int num1,num2,product;
  cout << "Enter first number: ";
  cin >> num1;
  cout << "Enter second number: ";
  cin >> num2;
  product = num1 * num2;
  cout << "The product is: " << product << endl;
  system("pause");
  return 0;
}
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.