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


Please Help Members By Posting Answers For Below Questions

What is a macro?

653


what value is returned to operating system after program execution?

1597


Explain what is the difference between a string and an array?

627


Why do we need functions in c?

551


What is preprocessor with example?

578






Is c pass by value or reference?

593


hai iam working in sap sd module for one year and working in lumax ind ltd in desp department but my problem is i have done m.b.a in hr/marketing and working sap sd there is any combination it. can you give right solution of my problem. and what can i do?

1654


What is pass by reference in c?

604


Write a program in c to replace any vowel in a string with z?

684


What is the explanation for prototype function in c?

564


What is scope rule of function in c?

542


What is c language used for?

553


What is indirection? How many levels of pointers can you have?

651


What is the difference between exit() and _exit() function in c?

578


how to make a scientific calculater ?

1559