Computer Science, asked by Ruoak, 11 months ago

Write an algorithm for maximum number for the given n numbers

Answers

Answered by 14ueee022
5

Answer:

First, Using Get function we can collect N numbers

and then, we need to store in array function

then, assign the first array element is the biggest one.

next, using looping statement, compare next array element to first assigned array element by if statement

then, if the second array element is higher then first one. assign second one is a bigger one and continue the loop by using continue statement.if it's not greater one . no need to change the first biggest value , simply put continue statement.

Finally, display the max value using print statement.

Explanation by program.

header

{

int a[100],N,max;

scanf("%d",&N);(get No of numbers)

for()

{

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

}

max=a[0];

for()

{

if(a[0]<a[I])

{ a[0]=a[1]

continue;

}

else

{ continue;

}

}

print (a[0]);

}

Similar questions