Design a program using an array that searches a number if it
is found on the list of the given input numbers and locate
its exact location in the list.
Answer Posted / dartz
#include<stdio.h>
#include<conio.h>
void main()
{
int ch[100],m,n,flag=0;
printf("enter the limit value");
scanf("%d",&m);
for(int i=0;i<m;i++)
scanf("%d",&a[i]);
printf("enter the number u are searching for :");
scanf("%d",&n);
for(i=0;i<m;i++)
{
if(a[i]==n)
{
printf("%d number is found at the position %d in the
given array ",n,i);
i=m;// to come out from the loop when we found
searching number
flag=1;
}
}
if( flag = 0)
{
printf(" given number is not found in the list of array");
}
getch();
}
| Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
What is 2 d array in c?
a c variable cannot start with a) an alphabet b) a number c) a special symbol d) both b and c above
How can I discover how many arguments a function was actually called with?
What is wild pointer in c?
Write a program to swap two numbers without using third variable?
Why is c so powerful?
Is it better to use malloc() or calloc()?
What is meant by int main ()?
When should a type cast be used?
given post order,in order construct the corresponding binary tree
What happens if header file is included twice?
Is there anything like an ifdef for typedefs?
What is huge pointer in c?
What is character constants?
What is the scope of an external variable in c?