Kode Hari Ini [18.11.17]
int main()
{
int batas;
int data[1010];
int tebak;
int flag = 0;
printf("Input the number of elements to be stored in the array: ");
scanf_s("%d", &batas);
fflush(stdin);
printf("Input %d elements in the array:\n", batas);
for (int i = 0; i < batas; i++)
{
printf("element - %d : ", i);
scanf("%d", &data[i]);
fflush(stdin);
}
printf("Input a value to search: ");
scanf_s("%d", &tebak);
for (int j = 0; j < batas; j++)
{
if (tebak == data[j])
{
printf("%d is found in the array.", tebak);
flag = 1;
break;
}
}
if (flag == 0)
{
printf("%d isn't found in the array.", tebak);
}
getchar();
return 0;
}
Comments
Post a Comment