Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
383 B
0
Indexable
Never
//Suma de los números enteros entre 1 y N.
#include <iostream>

using namespace std;

int main()
{
    int n, i = 1, sumatoria = 0;
    cout << "Ingrese el valor de N" << endl;
    cin >> n;
    while (i <= n)
    {
        sumatoria += i;
        cout << i << " ";
        i++;
    }
    cout << endl;
    cout << "La sumatoria es " << sumatoria;
    return 0;
}