0

anyone help with c++ programing for odd and even number where the program prompts the user to enter a guess and report the guess

5th May 2022, 9:26 PM
GIVEN NICOL
5 Answers
+ 4
Your are assigning value instead of comparing in both if statements Change =(assignment operators) to ==(comparators) in both cases
6th May 2022, 1:55 AM
AzhagesanăƒŸ(✿)
AzhagesanăƒŸ(✿) - avatar
+ 1
Can you show us your attempt?
5th May 2022, 10:03 PM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
iostream> #include <cstdlib> using namespace std; int main(){ int randomnumber; int n,even,odd; cout << "the random integer is\n"; randomnumber =(rand()%100); cout << randomnumber <<endl; cout << "is the number odd or even??\n"; even=( randomnumber % 2 == 0); odd=(randomnumber % 2!= 0); cin >>n; switch(n) { case 1: if (n=even){ cout<<" correct\n"; } else{ cout << " incorrect\n"; } break; case 2: if (n=odd){ cout << " correct\n"; } return 0;
5th May 2022, 10:05 PM
GIVEN NICOL
+ 1
#include <iostream> using namespace std; int main() { int num; cin>>num; if(num%2==0 && num>0) { cout<<"even"<<endl; } else if(num%2==1) { cout<<"odd"<<endl; } else { cout<<0; } return 0; }
7th May 2022, 4:08 AM
Amul Gaurav
Amul Gaurav - avatar
0
the user must guess weather the number is even or odd number
5th May 2022, 10:09 PM
GIVEN NICOL