About

Wednesday, 22 February 2012

PROGRAM DERET BILANGAN MENGGUNAKAN FOR

/*PROGRAM DERET BILANGAN MENGGUNAKAN FOR*/
#pragma argused
#include<conio.h>
#include<iostream.h>
#include<iomanip.h>


int main()
{
    
    int jumgen,jumgan,i,x,gan,gen,jum;

    
    cout<<"PROGRAM DERET BILANGAN MENGGUNAKAN FOR"<<endl;
    cout<<"----------------------"<<endl;
    cout<<endl;
    cout<<"Masukkan Jumlah Bilangan : ";
    cin>> x ;
    cout<<endl;
    cout<<endl;
    
    gan=1;
    gen=0;
    jumgan=0;
    jumgen=0;
    
    cout<<"No."<<setw(13)<<"Ganjil"<<setw(10)<<"Genap"<<endl;
    cout<<"---"<<setw(13)<<"------"<<setw(10)<<"-----"<<endl;
    
    for (i=1 ; i<=x ; i=i+1)
    {
        cout<<setw(2)<< i <<"."<<setw(10)<<gan <<setw(12)<< gen<<endl;
        jumgan=jumgan+gan;
        jumgen=jumgen+gen;
        gan=gan+2;
        gen=gen+2;
        }
        
        cout<<setw(10)<<"--------------------------"<<endl;
        cout<<setw(13)<<jumgan<<setw(12)<<jumgen<<endl;
        
    
        jum=jumgan+jumgen;
        cout<<endl;
        cout<<endl;
        cout<<"Jumlah Ganjil + Jumlah Genap = "<<jum<<endl;
        
        
        
        
        getch();
        }

Baca Juga Artikel dibawah ini :

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Bluehost Coupons