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 / vignesh1988i
here i have used a concpt of pointers .. ie. array of
pointers.... when you search for a number it may occur once
or more than it... i have designed for all cases.. that's
why i used pointers......................
#include<stdio.h>
#include<conio.h>
void main()
{
int ch[100],m,n,*ptr[20],count=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,k=0;i<m;i++)
{
if(a[i]==m)
{
count++;
ptr[k]=&a[i];
k++;
}
for(i=0;i<count;i++)
printf("the number occured %d times and found to be int
these addresses : %u ",count,*(*(ptr+i)));
getch();
}
| Is This Answer Correct ? | 1 Yes | 5 No |
Post New Answer View All Answers
What is 1d array in c?
Explain null pointer.
develop algorithms to add polynomials (i) in one variable
How do you use a pointer to a function?
What is sizeof return in c?
What is scope rule in c?
What is volatile c?
What are formal parameters?
What the advantages of using Unions?
Discuss the function of conditional operator, size of operator and comma operator with examples.
What are local static variables?
What are the types of variables in c?
in linking some of os executables are linking name some of them
What is a void pointer in c?
Is using exit() the same as using return?