diff --git a/sum.cpp b/sum.cpp new file mode 100644 index 00000000000..3642f0e6659 --- /dev/null +++ b/sum.cpp @@ -0,0 +1,16 @@ +#include +using namespace std; + +int main() { + int n, sum = 0; + + cout << "Enter a positive integer: "; + cin >> n; + + for (int i = 1; i <= n; ++i) { + sum += i; + } + + cout << "Sum = " << sum; + return 0; +}