I am a student in a computer programming class. I was instructed to write a program that would allow the user to input numbers and the program would output the sum of those numbers. I wrote the program up but keep getting this error message: error C2447: '{' : missing function header (old-style formal list?). I have no clue what this means. Can someone please help? I am a beginner so please keep it simple. Here is the program I wrote:

#include <stdio.h>
int input_number();
int main(void)
{
int numbers[100];
int counter;
int sum;
int number_elements;
    printf("The number of elements you want to use is ");
    scanf("%d",number_elements);
    sum=0;
    for (counter=1; counter<=number_elements; counter++)
        {
            numbers[counter]=input_number();
            sum=sum+numbers[counter];
            printf("The sum is %d",sum);
        }
    return 0;
}

int input_number();
{
int b;
printf("Input a number ");
scanf("%d",&b);
return b;
}

Edited 3 Years Ago by Dani: Formatting fixed

Make use of code tags else no one would even care to look at your code.If you use them it would look like this. For more information look here link

#include <stdio.h>
int input_number();
int main(void)
{
int numbers[100];
int counter;
int sum;
int number_elements;
printf("The number of elements you want to use is ");
scanf("%d",number_elements);
sum=0;
for (counter=1; counter<=number_elements; counter++)
{
numbers[counter]=input_number();
sum=sum+numbers[counter];
printf("The sum is %d",sum);
}
return 0;
}

int input_number();
{
int b;
printf("Input a number ");
scanf("%d",&b);
return b;
}

Errors:

Line 10 : It should be

scanf("%d",&number_elements);

Line 22 : It should just be

int input_number()
{
int b;

No semicolon after the input_number().

Edited 7 Years Ago by csurfer: n/a

This article has been dead for over six months. Start a new discussion instead.