1.

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

Answer»

Answer:

#include

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

{

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.



Discussion

No Comment Found