You are on page 1of 2

//ugyen norbu & phuntsho dema

#include<stdio.h>

int main()

//1.Declare the variables

int array[100],maximum,minimum,size,c,location=1;

//2.Ask the user to enter the element in the array.

printf("Enter the number of elements in array\n");

scanf("%d",&size);

printf("Enter %d integers\n",size);

for (c=0;c<size;c++)

scanf("%d",&array[c]);

maximum=array[0];

minimum=array[0];

//3.Display the maximum and minimum elements of the array.

//3.1.Assuming the first number as maximum.

for(c=1;c<size;c++)

if(array[c]>maximum);

maximum=array[c];

location=c+1;

printf("Maximum element is present at location %d and its value is %d.\n",location,maximum);

//3.2.Assuming the first number as minimum.

for(c=1;c>size;c++)

{
if(array[c]<minimum);

minimum=array[c];

location=c+1;

//If any number lesser than maximum is found then save its location.

printf("Minimum element is present at location %d and its value is %d.\n",location,minimum);

return 0;

You might also like