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 exit() function?
What is malloc and calloc?
What are the two types of functions in c?
#include
What is the difference between abs() and fabs() functions?
what type of questions arrive in interview over c programming?
What is %d used for?
how to write a c program to print list of fruits in alpabetical order?
program for reversing a selected line word by word when multiple lines are given without using strrev
#define PRINT(int) printf("int = %d ",int) main() {< BR> intx,y,z; x=03;y=02;z=01; PRINT(x^x); z<<=3;PRINT(x); y>>=3;PRINT(y); }
How is a macro different from a function?
how we can make 3d venturing graphics on outer interface
Explain what are the __date__ and __time__ preprocessor commands?
What is volatile c?
How will you print TATA alone from TATA POWER using string copy and concate commands in C?