C Program To Find Maximum Number In Array


♣ Try it Out ::
#include<stdio.h>
#include<conio.h>

main()
{
    int Array[100], MaxNum, Size, pos = 1, i;

    printf("How many numbers you wish to input in array: ");
    scanf("%d", &Size);

    printf("Enter %d integers: ", Size);
    for(i=0; i<Size; i++)
        scanf("%d", &Array[i]);

    MaxNum = Array[0];

    for(i=1; i<Size; i++)
    {
        if(Array[i] > MaxNum)
        {
            MaxNum = Array[i];
            pos = i + 1;
        }
    }

    printf("\nMaximum number is %d and it's position is %d.\n", MaxNum, pos);

    getch();
    return(0);
}

♣ Output ::
How many numbers you wish to input in array: 5
Enter 5 integers: 40 25 30 125 5

Maximum number is 125 and it's position is 4.

♣ Downloads ::

Comments

Popular posts from this blog

C++ :: Topological Sort Algorithm (using DFS)

How to Hack Facebook Account

C++ :: Strongly Connected Components Algorithm (SCC)