0

I wonder why I have to input two integers when running the program,while I just want to get the sum of 0 to the integer I input.Here's my code.

#include <stdio.h>

int input_integer(void);

int main(void){

    int j,a,m;
    j=0;
    a=0;
    m = input_integer();
    while(j<=m){
       a=a+j;
       j++;}
    printf("%d\n",a);



}

int input_integer(void){

    int n;
    scanf("%d\n",&n);
    return n;
}
tkausl
  • 13,686
  • 2
  • 33
  • 50

0 Answers0