31 Ağustos 2013 Cumartesi

Kullanıcının girdiği 2 sayı arasındaki sayıları toplayan program

Bu nasıl bir program ismidir diyip güldüm kendi kendime :D C++ kodu şöyle.Tamamiyle bana aittir hiç biryerden kopya çekmedim :D Daha kısa yolu varsa lütfen benimle paylaşın.



#include <iostream>
using namespace std;

int main()
{
// define two variables to sum of range of one to another

int no1 , no2 ; // two variables
cout << "Please enter first number ";
cin >> no1; // get number 1
cout << "Please enter second number";
cin >> no2; // get number 2
int x = 0;
do {
for (no1; no1 <= no2; no1++){
x += no1; // add all number 1s to itself until number 1 equals to number 2

}} while(no1==no2);
cout << x << endl;
return 0;

}

Hiç yorum yok:

Yorum Gönder