View Single Post
Old Nov 19th, 2006, 10:44 AM   #3
paulmedic555
Newbie
 
paulmedic555's Avatar
 
Join Date: Jan 2005
Location: Greece
Posts: 18
Rep Power: 0 paulmedic555 is on a distinguished road
Send a message via MSN to paulmedic555
I check the code from the beginning and i see my obvious mistakes.Now i scan all the array and keep max(the number) and k(the position) and print them in the end.So i updated and it works :
#include<stdio.h>
void main()
{
	int pin[10]={2,4,6,34,56,54,34,23,1,10},i,max,k;

	max=pin[0];
	for(i=0;i<10;i++)
	{
		if(pin[i]>=max)
		{
			max=pin[i];
			k=i;
		}
	}
	printf("The max number of the array is: %d and it is in  %d position of the array\n",max,k+1);
}
Thanks for your reply
paulmedic555 is offline   Reply With Quote