64.3k views
0 votes
Guys I should write the program in C++

Can u help me?


Write a program which reads numbers from keyboard in a loop and checks if the given number is even.
The program ends when a negative number is input.​

User Astqx
by
4.0k points

1 Answer

1 vote

#include <iostream>

int main(int argc, char const* argv[]) {

while(1) {

std::cout << ">> "; int x; std::cin>>x;

if(x<0) break;

else if(x%2==0) {std::cout << "\\This is even number.\\";}

else std::cout << "\\This is odd number.\\";

}

return 0;

}

Guys I should write the program in C++ Can u help me? Write a program which reads-example-1
User Viktor Carlson
by
4.5k points