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

Write a program to find factorial of a number using recursive function.

634


What does do in c?

599


Explain what is the difference between functions abs() and fabs()?

611


Sir i need notes for structure,functions,pointers in c language can you help me please

1939


What is difference between far and near pointers?

597






What are the rules for the identifier?

660


What is stack in c?

599


What are the 5 data types?

592


What is a lookup table in c?

618


Why doesnt the call scanf work?

658


How can you return multiple values from a function?

622


How many types of errors are there in c language? Explain

560


What is #include stdio h and #include conio h?

592


What is volatile c?

512


a character or group of characters that defines a register,or a part of storage a) memory b) byte c) address d) linear list

619