Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

write a function that accepts an integer/char array and an
search item.If the search item is there in the array return
position of array and value else return -1.without using
other array,without sorting,not to use more than one loop?

Answer Posted / p govind rao

#include<stdlib.h>
#include<stdio.h>
#define Max 6

int fun_rev(int *ptr, int num)
{
int i=0;
while(i<=Max)
{
if(num==*ptr)
{
return 1 ;
}
else
{
return 0;
}
i++;
ptr++;
}
}

int main()
{
int arr[Max]={3,4,5,6,2,1};
int item=6,result;
result=fun_rev(arr,item);
printf("result = %d",result);
return 0;
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how can f be used for both float and double arguments in printf? Are not they different types?

1026


What is the difference between abs() and fabs() functions?

1070


How do you view the path?

1085


What is a header file?

1039


What is null in c?

1016


How do I swap bytes?

1030


Why c is faster than c++?

988


Why c is called a middle level language?

1060


How does sizeof know array size?

1083


Explain what are header files and explain what are its uses in c programming?

1119


What are the uses of a pointer?

1114


Can you please explain the scope of static variables?

1004


What is structure data type in c?

982


Explain is it valid to address one element beyond the end of an array?

1156


Write a program to generate random numbers in c?

1058