Hey guys, i am having a problem solving a this part of my coding. Basically, what im doing is for the program to read a string, and if there is a value of 'M', the value of num will go up by 1000.
Here my coding ....
string msg ;
int n = 0;
int num ;
cout << "Enter the letter please ";
cin >> msg ;
const char* numeral = msg.c_str ();
cout << numeral << endl;
if (numeral[n] =='M')
{
num += 1000
n++;
cout << num << endl;
}
So, when i input in "MM" into the program, theorywise, my num value should be 2000 right? but for some reason, i keep getting a weird number .
Basically, my expected output will be, if there is 'a' amount of M in a string, the output will be (a * 1000). Could somebody point out my mistake in this.