473,396 Members | 1,655 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

C++ Programming

Hello everybody.
I want to write a program that the user enters 3 numbers and the output must distinguish which number is even and which is odd, using 2 void functions which will display those numbers and their kind (even or odd).
Can someone help me, because i out of ideas?

Thanks.
Dec 24 '07 #1
4 1070
Hi,

This is a very simple program and needs just 3-4 minutes. U said u ran out of ideas. Can i know what was u'r initially thought direction ? Try more folk it's really too simple.

Hint :: Just use the MOD operator or the BINARY OR.
Dec 24 '07 #2
Idriss
1
Hi,

This is a very simple program and needs just 3-4 minutes. U said u ran out of ideas. Can i know what was u'r initially thought direction ? Try more folk it's really too simple.

Hint :: Just use the MOD operator or the BINARY OR.

Hello there,

Well I'm not sure why you need two void functions to simply tell an odd number from even one, any way you might want to try this algorithm :

for i<3
function InputNumber(x)
y=x%2
i=i-1;
if y==1 then
return true;
else
return false ;

Hope that will help
Dec 24 '07 #3
sicarie
4,677 Expert Mod 4TB
So you need to design three different functions - your main(), your function to figure out if something is even, and your function to figure out if something is odd.

Assuming you know how to construct a main that asks for three variables, I would then start prototyping your even and odd functions. You are going to have to make a design decision here - are you going to pass all three variables to a function, and let it handle IO, or are you going to have your main() handle the IO based on the return of a single number?

Then that will lead you into your prototype, and two of the three things needed to prototype a function.

Once you have the prototype, you can then think about the implementation of the functions.
Dec 24 '07 #4
weaknessforcats
9,208 Expert Mod 8TB
What sicarie is using is the "divide-and-conquer". That is, when you can't of how to do something,you call a function that does it (even if no such function exists). Then inside that function there is yet a thing that you don't know how to solve, then call another function. Eventually, you will have called enougth functions that the code needed will be trivial.

Sometimes, this is called "top-down" programming.
Dec 24 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Martin | last post by:
When was inheritance intruduced into object oriented programming? More generally, does anyone know or have any sources on when the different features were introduced into object oriented...
12
by: G. | last post by:
Hi all, During my degree, BEng (Hons) Electronics and Communications Engineering, we did C programming every year, but I never kept it up, as I had no interest and didn't see the point. But now...
3
by: user | last post by:
Hi all, At the outset, I regret having to post this slightly OT post here. However, I strongly feel that people in this group would be the best to advise me on my predicament. I am working as...
134
by: evolnet.regular | last post by:
I've been utilising C for lots of small and a few medium-sized personal projects over the course of the past decade, and I've realised lately just how little progress it's made since then. I've...
7
by: Robert Seacord | last post by:
The CERT/CC has just deployed a new web site dedicated to developing secure coding standards for the C programming language, C++, and eventually other programming language. We have already...
30
by: Jakle | last post by:
I have been googling, but can seem to find out about C GUI libraries. My main platform is Windows, but it would be nice to find a cross platform library. I've been programming with php, which...
47
by: Thierry Chappuis | last post by:
Hi, I'm interested in techniques used to program in an object-oriented way using the C ANSI language. I'm studying the GObject library and Laurent Deniau's OOPC framework published on his web...
111
by: Enteng | last post by:
Hi I'm thinking about learning C as my first programming language. Would you recommend it? Also how do you suggest that I learn it?What books/tutorials should I read for someone like me? Thanks...
14
by: deko | last post by:
For building Windows desktop apps, the clear favorite is C#. But my clients can't afford to buy Microsoft products. So I need to develop software for Linux users and web applications. In the...
17
by: CoreyWhite | last post by:
I bought this book years ago, when I was just learning C++. Since then I've gone through every math course offered at my college, taken courses on coding C & thinking in terms how how to make the...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.