#include <stdio.h>
void main()
{
int arr[20], search, c, n;
printf("Enter 20 integer(s)\n");
for (c = 0; c < 20; c++)
scanf("%d", &arr[c]);
printf("Enter the number to search\n");
scanf("%d", &search);
for (c = 0; c < n; c++)
{
if (arr[c] == search) /* if required element found */
{
printf("%d is present at location %d.\n", search, c+1);
break;
}
}
if (c == n)
printf("%d is not present in array.\n", search);
getch();
}
void main()
{
int arr[20], search, c, n;
printf("Enter 20 integer(s)\n");
for (c = 0; c < 20; c++)
scanf("%d", &arr[c]);
printf("Enter the number to search\n");
scanf("%d", &search);
for (c = 0; c < n; c++)
{
if (arr[c] == search) /* if required element found */
{
printf("%d is present at location %d.\n", search, c+1);
break;
}
}
if (c == n)
printf("%d is not present in array.\n", search);
getch();
}
No comments:
Post a Comment