I wrote the code to calculate the sum up to a certain number n, if it is not a natural number to write that it is not, or if a number is not entered to say that it was not entered and the program stops working, all that is done, but it simply does not load this part below the if loop, how do I fix that and put returns or some other option?
int main() {
int i, n, s = 0;
printf("input n: ");
scanf("%d", &n);
if (n<0) {
printf(" Not natural number");return 0;}
if (n != scanf("%d", &n)) {
printf("No number!");return 0;}
for (i = 1; i <= n; i++)
s = s + i * i;
printf("s is: %d", s);
return 0;
}