Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.
/**Bismillahir Rahmanir Rahim.**/
#include <stdio.h>
int main()
{
int N;
printf("How Many Element Have on Your Array?\n");
scanf("%d", &N);
int DATA[N];
int K,LOC,MAX;
printf("Please, input %d Number.\n", N);
for(K=0; K<N; K++)
scanf("%d", &DATA[K]);
K=0; LOC = 0; MAX = DATA[0];
level:
K++;
if(K>=N)
{
printf("Max Value = %d Location = %d\n",MAX, LOC);
return 0;
}
if(DATA[K]>MAX)
{
MAX = DATA[K];
LOC = K;
}
goto level;
return 0;
}
0 comments:
Post a Comment
Note: only a member of this blog may post a comment.