turbo c looping

February 8, 2010 at 06:30:57
Specs: Windows XP
this code should ask for 5 numbers input then locate 1 input to where it was located ex. 5 4 3 2 1
enter number to be searched:4
for is located in location 2
my problem is on terminating the loop it loop til he got the max location i don't know how to terminate the loop when he proved it true now i'm stuck anyone can help me?

#include <stdio.h>
#include <conio.h>
int num[5];
int find;
int ctr;
main()
{ clrscr();
printf("enter a list of numbers:");
scanf("%d%d%d%d%d",&num[5]);
printf("enter a number to be Searched:");
scanf("%d",&find);
for(ctr=1;ctr<=5;ctr++)
if(find=num[ctr]);
printf("is found in:%d",ctr);

getch();


}


See More: turbo c looping

Report •


#1
February 19, 2010 at 06:35:14
for (ctr = 0; ctr < 5; ctr++)
if(find == num[ctr])
{
printf("is found in:%d", ctr);
break;
}


Report •
Related Solutions


Ask Question