Write a program to Sum of N Numbers in C++ Language - Program to Sum of N Number in C++

 Program to Sum of N Numbers in C++ Language

#include <iostream>

using namespace std;

int main() {

    int n, add = 0;

    cout << endl << "Enter a positive number: ";

    cin >> n;

    for (int i = 1; i <= n; ++i) {

        add += i;

    }

    cout << endl << "Sum of the given number is = "

    << add << endl;

    return 0;

}

इस कोड को हमने CODEBLOCK पर बना कर run किया है


OUTPUT


Comments