![]() |
|
#1
|
|||
|
|||
While and For Loop ProgramI have to create the exact same program, one using a for loop and the other using a while loop. The goal of the program is to input 10 numbers and then sum up the odd numbers and the even numbers, respectively. I think I have a good idea of what I'm supposed to do, but I'm stumped on how to sum up the odd and even numbers. It's probably something very simple, but i'm very new to C++. The 2 programs only output "The sum of the even numbers is: 10" (which it's not because I entered the numbers 1-10) and it is supposed to output the sum of the even and odd numbers.
While CPP / C++ / C Code:
For CPP / C++ / C Code:
|
|||
|
#2
|
|||
|
|||
Re: While and For Loop ProgramYou just put the 10 number in array and do the checking.
CPP / C++ / C Code:
|
|
#3
|
||||
|
||||
Re: While and For Loop ProgramPerhaps something like this (both combined into one program):
CPP / C++ / C Code:
MxB |
|
#4
|
|||
|
|||
Re: While and For Loop ProgramThank you! I see that I almost had it correct, I just had the if/else statements in the wrong place.
Thanks again, you were a lot of help. |
Recent GIDBlog
Toyota - 2009 May Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The