Computer Science, asked by malinivenkat2000, 9 hours ago

find the sum of largest and smallest number in an array in c program

Answers

Answered by svvsnagesh
4

Answer:

#include<stdio.h>

int main()

{

int a[10],I,n,large,small;

print("\n Enter the number of elements : ");

scanf("%d",&n);

print("\n Input the array elements : ");

for( i=0;i<n;++i)

scanf ("%d",&a[i]);

large=small=a[0];

for(i=1;i<n;++i)

{

if (a[i]>large)

large=a[i];

if(a[i]<small)

small=a[i];

}

printf ("\n the smallest element Is %d\n",small);

printf("\n The largest element is %d\n",large);

return 0;

}

OUTPUT :

Enter the number of elements : 3

Input the array elements : 2 4 6

The smallest element is : 2

The largest element is : 6

Answered by venom005
0

Explanation:

#include<stdio.h>

#include<conio.h>

void main()

{

int a[5], i,big=0,small=0,sum=0;

for (i=0;i<5;i++)

{

printf("enter the number: ");

scanf("%d",&a[i]);

if(i==0)

{

small=a[i];

}

}

for (i=0;i<5;i++)

{

(small>=a[i])

{

small=a[i];

}

for(i=0;i<5;i++)

{

if (big<=a[i])

{

big=a[i];

}

}

printf("smallest element:%d\n",small);

printf("biggest element:%d\n",big);

}

}

Similar questions