one cout problem

the problem is to read 2 integers and using only 1 cout; we have to print if they are even or odd

example:

input:
2
3

output:
even odd
If you can read, you can find out the answer in the tutorial lol (supposing you can understand it).
could u plz tell me the link bcoz this tutorial is not so small i suppose!!!!!!!!
Well.. to read the integers you'd use cin >> (yes, there are better solutions, but that is a simple way). The integers could be 2 variables, so let's say 'X' and 'Y'. Then just do something like if (x % (modulo)) {cout << "Even."} else {cout << "Odd".}
you didnt get the problem man--------we had to use only 1 cout???
got it now!!!!!!!
Man, that was so rude, it doesn't even deserve an answer. If was you, I'd blank my post.

EDIT: The hell...?
Last edited on
oh!!!!
whats rude in that?????be professional

ok if u feel bad, then i am sorry.

now can u plz help me
Dude. I even GAVE you like, what, half the answer -if not more! Use your BRAINS. They're there for a reason. You didn't even attempt your stupid question, and now all you're doing is making other people do your work for you.
isnt that rude on ur part now

i just asked 1 ques-----if u knew it u could have answered it else not?
why fight with each other!!!
I think you don't understand. This is a C++ Forum, not a "Hey look finish my homework NOW" forum.

EDIT: Reading this thread might help. http://www.cplusplus.com/forum/beginner/1/
Last edited on
Professional? I'm professional when I'm getting paid. And even then I have the right to find rude whatever I feel like. In this case, your grammar, spelling, punctuation, and syntax tell me you're being rude. Even your pseudo-apology is rude.
If you can't convey your meaning in a text-only medium, you should probably go back to (or stay longer in) school, because writing is a basic human skill.

EDIT: Right, I forgot that. Following the rules of the surrounding community is also pretty basic.
Last edited on
I quote helios.
............................................________
....................................,.-‘”...................``~.,
.............................,.-”...................................“-.,
.........................,/...............................................”:,
.....................,?......................................................\,
.................../...........................................................,}
................./......................................................,:`^`..}
.............../...................................................,:”........./
..............?.....__.........................................:`.........../
............./__.(.....“~-,_..............................,:`........../
.........../(_....”~,_........“~,_....................,:`........_/
..........{.._$;_......”=,_.......“-,_.......,.-~-,},.~”;/....}
...........((.....*~_.......”=-._......“;,,./`..../”............../
...,,,___.\`~,......“~.,....................`.....}............../
............(....`=-,,.......`........................(......;_,,-”
............/.`~,......`-...............................\....../\
.............\`~.*-,.....................................|,./.....\,__
,,_..........}.>-._\...................................|..............`=~-,
.....`=~-,_\_......`\,.................................\
...................`=~-,,.\,...............................\
................................`:,,...........................`\..............__
.....................................`=-,...................,%`>--==``
........................................_\..........._,-%.......`\
...................................,<`.._|_,-&``................`\
this is a good method to increase your posts
go on
i will not mind
Some people deserve to be shot...
@ Priptal singh

use the ternary operator
(condition) ? (result if true) : (result if false)
and the cout << operator
cout << "something" << "something";

Tutorials:
http://www.cplusplus.com/doc/tutorial/operators.html
http://www.cplusplus.com/doc/tutorial/basic_io.html
Last edited on
cout << (n%2==0 ? "Even" : "odd");
Although I'm not really sure if that will work.
try building a string, after you get the two inputs call a function that builds the correct string and then cout that one
thanks gen1mx6
it worked
Topic archived. No new replies allowed.