Hi! I need some help with a VERY simple program I'm making. It's a calulator that adds two numbers and uses arrays. I've just been doing this for a few days, so don't flame on me. This is the code:
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
int x[3];
x[2]=x[0]+x[1];
int main(int argc, char *argv[])
{
//Prints instructions
cout << "This is a simple calculator. All it does" << endl;
<< "is add two numbers." << endl << "Please insert "
<< "your first number, press Enter, " << endl
<< "then the second and Enter."
//Asks for the first number and to press Enter
cin >> x[0] >> getch();
//Displays the plus sign
cout << " + ";
//Asks for the second number and to press Enter
cin >> x[1] >> getch();
//Displays the equal sign and the answer
cout << " = " x[2] << endl
//Prints instructions
<< "Please press Enter to exit this program.";
//Waits until user presses Enter
getch();
//Closes the program
return 0;
}
What's wrong? Could someone please help me? Happy holidays!
-scary_freak_x



LinkBack URL
About LinkBacks



