So there was this problem where we had to find sum of N natural numbers, given the input N.
I wrote this code and the outputs match all sample outputs. Why is it printing it as wrong answer?
This is the code:
#include <iostream>
using namespace std;
int main() {
int N,sum=0;
cin>>N;
for(int i=1;i<=N;i++)
{
sum+=i;
}
cout<<sum<<endl;
}