you have actually made mistakes of putting unnecessary braces .
first of all in the functions findmax and findmin u have put extra braces.
secondly in function findmin u have declared variable min and using max for comparison
In the main function while u are printing numbers in reverse order u are also repeatedly printing the sum,largest and smallest
number statements again and again by putting inside the for loop.
you can use either int/void main().
your char answer was not intially set as 'y' neither are u asking the user whether he is willing to use the program again.u als need only 1 char not an array
The variable sum was not intialized to zero
in the scanf statement u missed & operator therefore numbers were not stored at the variable
some xtra features can be that when user wishes to quit u can use exit(0) function when he presses 'n'
u should also use clrscr() for wiping out previous contents
the new program is this:
Code:
/*
Filename: sum.c
Description: This program computes the sum, the largest and smallest of these integers.
*/
#include <stdio.h>
#include<conio.h>
#include<stdlib.h>
int findmax(int number [10]);
int findmin(int number [10]);
void main()
{
int number[10];
int i,sum=0;
char answer='y' ;
clrscr();
while(answer=='y')
{
printf ("Enter 10 non-negative numbers:\n");
for (i=0;i<10;i++)
{
scanf ("%d",&number[i]);
sum=sum + number[i];
}
printf("\n\n");
for (i=9;i>=0;i--)
{
printf ("%d\n",number[i]);
}
printf ("The sum is %d\n",sum);
printf ("The largest integer entered was %d\n",findmax(number));
printf ("The smallest integer entered was %d\n",findmin(number));
printf("You want to enter another set of numbers\n");
scanf("%c",&answer);
if(answer=='n')
exit(0);
}
getch();
}
int findmax (int number[10])
{
int max,i;
max=number[0];
for (i=0;i<10;i++)
{
if (max<number[i])
max=number[i];
}
return max;
}
int findmin (int number[10])
{
int min,i;
min=number[0];
for (i=0;i<10;i++)
{
if (min>number[i])
min=number[i];
}
return min;
}