informaticage

ACE C++ Esercizio 2

Apr 14th, 2021
768
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int main() {
  5.   // n1 ed n2 sono gli estremi dell'intervallo di numeri da sommare
  6.   int n1, n2;
  7.   cout << "Inserire n1, n2 (n2 >= n1): ";
  8.   cin >> n1 >> n2;
  9.  
  10.   int i = n1, somma = 0;
  11.   while (i <= n2) {
  12.     somma = somma + i;
  13.     i++;
  14.   }
  15.  
  16.   cout << "La somma dei numeri compresi tra n1 ed n2 e': " << somma;
  17.   return 0;
  18. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×