Bilangan Ganjil-Genap CPP

Thursday, February 28, 2013

#include <iostream>
#include <windows.h>

using namespace std;

int main()
{
    int bilangan;
    int genap=0, ganjil=0;
   
    cout << "Batas bilangan (0-70.000) : ";
    cin >> bilangan;
   
    for(int h=0; h<bilangan; h++)
    {
        if(h%2 == 0)
            genap++;
        else
            ganjil++;
    }
   
    endl(cout);
   
    cout<<"Banyak bilangan genap : "<<genap<<endl;
    cout<<"Banyak bilangan ganjil : "<<ganjil<<endl;
   
   
    system("pause");
    return 0;
}
Share this article :

0 comments:

Speak up your mind

Tell us what you're thinking... !

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Fahri Atala's blog - All Rights Reserved
Template Created by Creating Website Inspired by Sportapolis Shape5.com
Proudly powered by Blogger