#include <iostream>using namespace std;int main(){ char indicator = 'y'; while ( indicator == 'y' || indicator == 'Y' ) { int value[2] = { 0, 0 }; char changeable[10] = { 0 }; int count = 0; cin.getline( changeable, 10, ' ' ); if ( ( changeable[0] == 'a' ) & ( changeable[1] == 'd' ) * ( changeable[2] == 'd' ) ) { cin>> value[0] >> value[1]; cout<< value[0] + value[1] << endl; } if ( ( changeable[0] == 'm' ) & ( changeable[1] == 'i' ) & ( changeable[2] == 'n' ) & ( changeable[3] == 'u' ) & ( changeable[4] == 's' ) ) { cin>> value[0] >> value[1]; cout<< value[0] - value[1] << endl; } if ( ( changeable[0] == 's' ) & ( changeable[1] == 'u' ) & ( changeable[2] == 'b' ) & ( changeable[3] == 's' ) & ( changeable[4] == 't' ) & ( changeable[5] == 'r' ) & ( changeable[6] == 'a' ) & ( changeable[7] == 'c' ) & ( changeable[8] == 't' ) ) { cin>> value[0] >> value[1]; cout<< value[0] / value[1] << endl; } if ( ( changeable[0] == 'm' ) & ( changeable[1] == 'u' ) & ( changeable[2] == 'l' ) & ( changeable[3] == 't' ) & ( changeable[4] == 'i' ) & ( changeable[5] == 'p' ) & ( changeable [6] == 'l' ) & ( changeable[7] == 'y' ) ) { cin>> value[0] >> value[1]; cout<< value[0] * value[1] << endl; } cout<<"Do you want to do this again ( y or n )?: "; cin>> indicator; } return 0;}
This is what goes wrong:
http://img166.imageshack.us/img166/4156/naamlooshy0.jpg
EDIT
Improved it a little bit:
#include <iostream>using std::cout;using std::cin;using std::endl;int main(){ int value[2] = { 0, 0 }; char x[10]; int array_number = 0; int count = 0; char indicator = 'y'; while ( indicator == 'y' || indicator == 'Y' ) { cin.getline( x, 10, ' ' ); while ( x[count] != '\0' ) count++; if ( count == 3 ) { if ( ( x[0] == 'a' ) && ( x[1] == 'd' ) && ( x[2] == 'd' ) ) { cin>> value[0] >> value[1]; cout<<"The result is: " << ( value[0] + value[1] ) << endl; } } if ( count == 8 ) { if ( ( x[0] == 'm' ) && ( x[1] == 'u' ) && ( x[2] == 'l' ) && ( x[3] == 't' ) && ( x[4] == 'i' ) && ( x[5] == 'p' ) && ( x[6] == 'l' ) && ( x[7] == 'y' ) ) { cin>> value[0] >> value[1]; cout<<"The result is: " << ( value[0] * value[1] ) << endl; } } if ( count == 6 ) { if ( ( x[0] == 'd' ) && ( x[1] == 'i' ) && ( x[2] == 'v' ) && ( x[3] == 'i' ) && ( x[4] == 'd' ) && ( x[5] == 'e' ) ) { cin>> value[0] >> value[1]; cout<<"The result is: " << ( value[0] / value[1] ) << endl; } } if ( count == 5 ) { if ( ( x[0] == 'm' ) && ( x[1] == 'i' ) && ( x[2] == 'n' ) && ( x[3] == 'u' ) && ( x[4] == 's' ) ) { cin>> value[0] >> value[1]; cout<<"The result is: " << ( value[0] - value[1] ) << endl; } } cout<<"Do you want to do this again?:"; cin>> indicator; } return 0;}
[Edited by - Vinniee on December 17, 2006 1:06:22 PM]