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 #include conio h?
What does typedef struct mean?
When should the volatile modifier be used?
What are the features of c language?
List the difference between a "copy constructor" and a "assignment operator"?
What is the difference between volatile and const volatile?
What is a 'null pointer assignment' error?
how many types of operators are include in c language a) 4 b) 6 c) 8 d) 12
What is c basic?
if a is an integer variable, a=5/2; will return a value a) 2.5 b) 3 c) 2 d) 0
When should a type cast be used?
how to capitalise first letter of each word in a given string?
What is extern c used for?
What does the format %10.2 mean when included in a printf statement?
I came across some code that puts a (void) cast before each call to printf. Why?