Wlcome to the blogging tifani

contoh do while C++ program menghitung jumlah diantara dua bilangan

Sabtu, 11 Oktober 20140 komentar

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
using namespace std;
int main()
{
int a,b,jumlah;
cout<<"==menghitung jumlah antara dua bilangan===\n";
cout<<"Input angka awal : ";
cin>>a;
cout<<"Input angka akhir : ";
cin>>b;
if (a==b)
cout<<" jumlah = 0";
else if (a<b)
{jumlah=0;
do
{
a++;
jumlah=a+jumlah;
}
while (a!=(b-1));
cout<<"jumlah = "<<jumlah;
}
else
{jumlah=0;
do
{
a--;
jumlah=a+jumlah;
}

while (b!=(a-1));
{
cout<<"jumlah = "<<jumlah;
}
}}


Share this article :

Posting Komentar

 
Support : Cara Gampang | Creating Website | Johny Template | Mas Templatea | Pusat Promosi
Copyright © 2015. TIfanie - All Rights Reserved
Template edited by Creating Website Modify by Teknologi Informasi kinie
Proudly powered by Blogger