I am trying to ask the user to enter numbers until the total is more than 30 and counting odd and even numbers. I am really stuck any help would be appreciated.
#include <iostream>
#inlcude <string>
using namespace std;
int main(){
int integer = 0;
int total = 0;
int even_cout = 0;
int odd_cout = 0;
cout << "Total is " << total << endl;
while ( total <= 30 && integer <= 30 ) {
cout << "Please enter an integer: ";
cin >> integer;
total = integer + total;
if (toal < = 30) {
cout << "Total is " << total << endl;
}
if ( integer % 2 == 0) {
even_cout = even_cout + 1;
}
if (integer %2 == 1) {
odd_cout = oss_ cout + 1;
}
}
cout << "You had " << even_cout << " even numbers and " << odd_cout << " odd numbers." << endl;
return 0;
}
1. "#inlcude <string>" is wrong
2."if (toal < = 30) {" we do not have a varible named toal!!! and we do not have operator like "< =" it should be <= without space
3. "odd_cout = oss_ cout + 1;" also we do not have the variable oss_count
* Do you have a problem with compiling? The compiler does give error messages that tell what it sees as syntax errors. Those messages are very useful. If you have them, then show them. Eventually, you will learn to read them.
* Does the program compile, but crash when run? Syntax was legal, but logic was flawed.
* Does the program compile and run, but the results are unexpected? Still an error in logic.
Well, obviously I should have proofread that before I posted. My bad-
#include <iostream>
using namespace std;
int main(){
int integer = 0;
int total = 0;
int even_cout = 0;
int odd_cout = 0;
cout << "Total is " << total << endl;
while ( total <= 30 && integer <= 30 ) {
cout << "Please enter an integer: ";
cin >> integer;
total = integer + total;
if (toatl <= 30) {
cout << "Total is " << total << endl;
}
if ( integer % 2 == 0) {
even_cout = even_cout + 1;
}
if (integer %2 == 1) {
odd_cout = odd_ cout + 1;
}
}
cout << "You had " << even_cout << " even numbers and " << odd_cout << " odd numbers." << endl;
return 0;
}
I keep getting this error ==================== YOUR OUTPUT =====================
0001: [NONE]
=================== MISMATCH FOUND ON LINE 0001: ===================
ACTUAL : [NONE]
EXPECTED: Total~is~0
======================================================