Math, asked by Juhishrita4304, 1 year ago

Write a program to read 10 integers in an array. find the largest and smallest number

Answers

Answered by RaviKumarNaharwal
11
include<stdio.h> 
int main() 

int arr[10],small,big,i; 
for(i=0;i<10;i++) 

scanf("%d",&arr[i]); 
if(i==0) 
{small=big=arr[i];} 
if(arr[i]<small) 
small=arr[i]; 
if(arr[i]>big) 
big=arr[i]; 

printf("Smallest element = %d \n Biggest element = %d",small,big); 
return 0; 
}

Answered by Chaitanya1696
0

Below is the program to read 10 integers in an array and print the maximum and minimum of it.

include<stdio.h>

int main()

{

int arr[10],small,big,i;

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

{

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

if(i==0)

{small=big=arr[i];}

if(arr[i]<small)

small=arr[i];

if(arr[i]>big)

big=arr[i];

}

printf("Smallest element = %d \n Biggest element = %d",small,big);

return 0;

}

Similar questions