C++ School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a C++ Expert!

Join 307,165 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,555 people online right now. Registration is fast and FREE... Join Now!




even and odd numbers

 

even and odd numbers, help with even and odd numbers

philip soraghan

9 Nov, 2008 - 04:17 PM
Post #1

New D.I.C Head
*

Joined: 3 Apr, 2008
Posts: 9

hi there i need help finding the sum of a set of even and odd integers in a set of integers like 4567 odds would be 12 evens would be 10 all i get is if i enter 4567 i get 4567 and 0
CODE

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    int limit;
    int number;
    
    int sumeven=0;
    int sumodd=0;
    int count =0;
    cout<<"Enter limit of numbers "<<endl;
    cin>>limit;
    cout<<"Enter number"<<endl;
    cin>>number;


  
    if (number % 2 ==0)
{
    sumeven = count + number;
    count++;

  

}

cout<<"The sum of the even numbers are "<<sumeven<<endl;
    cout<<"The sum of the odd  numbers are "<<sumodd<<endl;
          

  
    system("PAUSE");
    return EXIT_SUCCESS;
}


User is offlineProfile CardPM
+Quote Post


Posts in this topic
philip soraghan   even and odd numbers   9 Nov, 2008 - 04:17 PM
GWatt   You need to break up the number into digits. The e...   9 Nov, 2008 - 04:31 PM

Reply to this topicStart new topic

Time is now: 11/21/09 06:11PM

Live C++ Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month