Computer Science, asked by AnuragYadav1221, 1 year ago

write a program in c to find the largest of any 20 given integers​

Answers

Answered by shamvishnu16
2

Answer:

#include<stdio.h>

int main()

{

int array[20],largest;

//get input from user

printf("\nEnter the 20 Numbers:");

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

{

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

}

largest=array[0];

//time complexity n

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

{

if(array[i]>largest)

{

largest=array[i];

}

}

printf("\nThe Largest Number is:%d",largest);

}

Explanation:

Get the Numbers from the user.

Store the First in a variable.

Compare the next 19 with that

If greater replace it or else just carry on to the next iteration.

that's it at last you have the largest number of any given numbers.

Similar questions