getting an error that it fulfills all public test cases but gives WA
because I’m a beginner I could not figure out what the error is Add Natural Numbers | CodeChef
my code #include
using namespace std;
int main()
{
long long int N;
cin>>N;
long long int sum=0;
if(N>0){
for(int i=1;i<=N;i++){
sum+=i;
}
}
printf(“%d”,sum);
}
[simon@simon-laptop][08:36:22]
[~/devel/hackerrank/otherpeoples]>./compile-latest-cpp.sh
Compiling sjswaroop2400-ADDNATRL.cpp
+ g++ -std=c++14 sjswaroop2400-ADDNATRL.cpp -O3 -g3 -Wall -Wextra -Wconversion -DONLINE_JUDGE -D_GLIBCXX_DEBUG -fsanitize=undefined -ftrapv
sjswaroop2400-ADDNATRL.cpp: In function ‘int main()’:
sjswaroop2400-ADDNATRL.cpp:13:16: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
printf("%d",sum);
^
+ set +x
Successful