answersLogoWhite

0


Best Answer

#include <iostream>

int main()

{

int num;

std::cout << "Enter a number: ";

std::cin >> num;

if(num % 2 == 0)

{

std::cout << "Number is even";

}

else

{

std::cout << "Number is odd";

}

return 0;

}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Even or odd in c plus plus program?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you write a C program to check whether the number is odd or even Ps-using DEV complier?

To write a C program to determine if something is odd or even you need to be a programmer. To write a program in C is complicate and only done by programmers.


If n is an odd integer is n plus 6 odd as well?

Yes. If n is odd, then n + c where c is an even constant will be odd. n + d where d is an odd constant will be even.


How do you make a program that display odd number from one to twenty in c plus plus?

for (int i=1; i&lt;20; i+=2) printf ("%d\n", i);


Create a c plus plus program that displays odd numbers between 15 and 30?

for (int i = 15; i &lt; 30; i += 2) cout &lt;&lt; i &lt;&lt; endl;


Can you add 2 odd numbers that equal an odd number?

no, b/c you can think of an odd number as an even number plus one. So if you add two odd numbers, you would be adding 2 even numbers plus 2... Let # be even... (#+1) + (#+1) = (#+#) + 2 two even numbers added together are always even


Can you program games with c plus plus?

Yes, you can program games with C++.


Write a program in c that prompt user with following lines add two integers test an integer for odd or even and quit?

write a program in C that prompts the user with the following lines: a) Add two integers c) Compare two integers for the larger t) Test an integers for odd or even q) Quit


C program to accept a sequence of number terminated by zero and sum all odd nos and even nos?

#include &lt;stdio.h&gt; main() { int n, odd=0, even=0; while (scanf("%d",&amp;n)&amp;&amp;(n!=0)) (n%2)?++odd:++even; printf("odd: %d even: %d\n",odd,even); }


Write c program to find odd or even no?

For any number n you could use * (n % 2 == 0), which would be true for an even number, false for odd For an integer i, a simpler method would be * (i &amp; 1), which would be true for an odd number, false for even


How to restart c plus plus program?

Exit the program and relaunch it.


What is odd loop in 'C' program?

odd loop means at least the loop execute once.


How we can write a program in C plus plus that takes a number from the user and prints whether it is even or odd?

#include &lt;iostream&gt; using namespace std; int main() { int x; cout &lt;&lt; "Enter a number: "; cin &gt;&gt; x; if(x % 2 == 0) { cout &lt;&lt; x &lt;&lt; " is even" &lt;&lt; endl; } else { cout &lt;&lt; x &lt;&lt; " is odd" &lt;&lt; endl; } char wait; cin &gt;&gt; wait; return 0; }