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
Tell me about low level programming languages.
what is different between auto and local static? why should we use local static?
If one class contains another class as a member, in what order are the two class constructors called a) Constructor for the member class is called first b) Constructor for the member class is called second c) Only one of the constructors is called d) all of the above
Why functions are used in c?
What is structure in c explain with example?
How old is c programming language?
What is the difference between volatile and const volatile?
How do you list a file’s date and time?
writ a program to compare using strcmp VIVA and viva with its output.
Find MAXIMUM of three distinct integers using a single C statement
What is a #include preprocessor?
Write a program to print fibonacci series without using recursion?
using for loop sum 2 number of any 4 digit number in c language
List out few of the applications that make use of Multilinked Structures?
Can we declare function inside main?