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 / ashwin kumar
dear no need of pointer for the above Question dear
#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 ? | 0 Yes | 1 No |
Post New Answer View All Answers
Why main function is special give two reasons?
Is javascript based on c?
What is a memory leak? How to avoid it?
What are c header files?
What is the process to create increment and decrement stamen in c?
Explain the difference between strcpy() and memcpy() function?
Write a program in "C" to calculate the root of a quadratic equation ax^2+bx+c=0, where the value of a,b & c are known.
What is stack in c?
void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }
What is 1f in c?
Why clrscr is used in c?
Explain can static variables be declared in a header file?
What is the difference between volatile and const volatile?
Can we declare variable anywhere in c?
Write a program to reverse a string.