Since this is a pretty basic program, why not try to demonstrate some of the basic rules:
1) Always initialize your variables.
Code:
double numInput[100] = {0};
char signInput[100] = {0};
double answer = 0;
2) Use read statements in a loop conditional. If there are any stream errors, the loop will terminate and not vainly try to read in more data or enter into an infinite loop. Your program can enter into an infinite loop if a stream error occurs while reading the data.
You could actually do this:
Code:
for(int x = 0; (cin>>numInput[x]>>signInput[x]) && (signInput[x] != '='); ++x)
but you might want to opt for the more readable:
Code:
int x = 0;
while( cin>>numInput[x]>>signInput[x] && signInput[x] != '=' )
{
++x;
}
or,
Code:
int x = 0;
while( cin>>numInput[x]>>signInput[x] )
{
if(signInput[x] == '=')
break;
++x;
}
3) Check for bad input. Currently your program crashes.
You think this is worthy of sending into the website to be posted?
It's posted right now. Tell your mom you're famous.