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
Compare array data type to pointer data type
Program to find the sum of digits of a given number until the sum becomes a single digit. (e.g. 12345=>1+2+3+4+5=15=>1+5=6)
how we can make 3d venturing graphics on outer interface
How to write c functions that modify head pointer of a linked list?
Give differences between - new and malloc() , delete and free() ?
what do you mean by enumeration constant?
main(){char *str;scanf("%s",str);printf("%s",str); }The error in the above program is: a) Variable 'str' is not initialised b) Format control for a string is not %s c) Parameter to scanf is passed by value. It should be an address d) none
Explain what is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?
What is the use of #include in c?
What does 3 mean in texting?
Is there a way to switch on strings?
Explain is it valid to address one element beyond the end of an array?
What is the stack in c?
What is meant by initialization and how we initialize a variable?
In a switch statement, explain what will happen if a break statement is omitted?