Thursday, July 30, 2009

Help turbo c problem. how do i solve this?

this problem here might be way too easy for professionals but im only a beginner and a student. help.





/*Program description: Write a program that will allow you to enter an integer and tell wether the integer is odd or even?*/





thank you.. i really need help..


:D

Help turbo c problem. how do i solve this?
Hope this helps:





this is made is visual studio 2005 (look at the next)





#include %26lt;iostream%26gt;


using namespace std;


void main()


{


int i;


cout%26lt;%26lt;"Please enter an integer: ";


cin%26gt;%26gt;i;


if (i%2)


cout%26lt;%26lt;"It's Odd"%26lt;%26lt;endl;


else


cout%26lt;%26lt;"It's Even"%26lt;%26lt;endl;


cin%26gt;%26gt;i;





}





in plain C it should be





#include %26lt;iostream.h%26gt;


void main()


{


int i;


cout%26lt;%26lt;"Please enter an integer: ";


cin%26gt;%26gt;i;


if (i%2)


cout%26lt;%26lt;"It's Odd"%26lt;%26lt;endl;


else


cout%26lt;%26lt;"It's Even"%26lt;%26lt;endl;


cin%26gt;%26gt;i;//you can cut this line, it's used just so that you see the result





}





Good luck!
Reply:Here is somthing to get u started :


1) prompt the user : pleas enter an integer


2) take the input from the user


3) validate the input - to make sure integer is entered


4) take the number and divide by 2 , store the remainder


5) if remainder = 0 , than number = even , else "the number is odd"





Hope this helps
Reply:IntA


IntB=IntA+1


IntC=IntA/2


IntD=IntB/2


if IntC=IntD then IntA is even








To use remainder method result needs to go into a float type variable
Reply:WELL, TRY CONSULTING YOUR TEACHER OR A RELATIVE OR A FRIEND OR ANYONE WHO UNDERSTANDS YOU AND YOUR PROBLEM. I KNOW IM NOT MUCH OF A HELP THOUGH. WELL TRY YOUR BEST TO SOLVE YOUR PROBLEM OKAY?!

gifts

No comments:

Post a Comment