#include<stdio.h>
#define SIZE 5
void main()
{
int arr[SIZE], max=0, min=arr[0], i, j, k, l, temp=0;
float avrg, sum=0;
printf("Enter 5 integers: ");
for(i=0;i<5;i++){
scanf("%d", &arr[i]);
sum = sum+arr[i];
if(arr[i]>max)
max=arr[i];
if(arr[i]<min)
min=arr[i];
}
avrg=sum/5;
printf("Sum of 5 integers = %.2f\n", sum);
printf("Average of 5 integers = %.2f\n", avrg);
printf("Maximum: %d\n", max);
printf("Minimum: %d\n", min);
printf("Reverse of 5 integers: ");
for(j=SIZE-1;j>=0;j--){
printf("%d ", arr[j]);
}
printf("\n");
for(l=0;l<SIZE;l++){
for(k=0;k<SIZE-1;k++){
if(arr[k]>arr[k+1]){
temp=arr[k];
arr[k]=arr[k+1];
arr[k+1]=temp;
}
}
}
printf("Sorted: ");
for(k=0;k<SIZE;k++){
printf("%d ", arr[k]);
}
}
Source code download here
0 comments:
Post a Comment