#include<stdio.h>
#include<conio.h>
main()
{
clrscr();
double sales[10];
int index;
double largestsale,smallestsale,sum,average;
//initializing
for(index=0;index<5;index++)
sales[index]=0.0;
//reading
printf("Enter Value:\n");
for(index=0;index<5;index++)
scanf("%d",&sales[index]);
//printing
for(index=0;index<5;index++)
if(sales[index]<index)
printf("%2d",sales[index]);
//sum & average
sum=0;
for(index=0;index<5;index++){
sum = sum+sales[index];}
average = sum/5;
printf("\nThe Sum is %d",sum);
printf("\nThe Average is %d",average);
//largestsale
int maxIndex = 0;
for(index=1;index<5;index++)
if(sales[maxIndex] < sales[index])
maxIndex = index;
largestsale = sales[maxIndex];
printf("\nLargestsale is %d",largestsale);
//smallestsale
int minIndex = 0;
for(index=1;index<5;index++)
if(sales[minIndex] > sales[index])
minIndex = index;
smallestsale = sales[minIndex];
printf("\nSmallestsale is %d",smallestsale);
getch();
return 0;
}
Shodow 3 Junior Poster
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
Shodow 3 Junior Poster
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
Shodow 3 Junior Poster
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.