Solution 5:
The program is as follows:
#include
#include
void main( )
{
int a[90], big, pos, i, n;
clrscr( );
printf(“\nEnter the size of the array:”);
scanf(“%d”, &n);
printf(“\nEnter the array elements:”);
for (i =0; i scanf(“%d”, &a[i]);
big = a[0]; /*assume 1
st
element is the largest one */
pos = 0; /*set the position of big as 0 */
for (i=1; i {
if (a[i] > big)
{
big = a[i];
pos = i;
}
}
pos++; /*increment pos by 1 as array is counted from 0 */
printf(“\nLargest number =%d is stored at position = %d”, big, pos);
getch( );
}
Do'stlaringiz bilan baham: