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
how can f be used for both float and double arguments in printf? Are not they different types?
What is the difference between abs() and fabs() functions?
How do you view the path?
What is a header file?
What is null in c?
How do I swap bytes?
Why c is faster than c++?
Why c is called a middle level language?
How does sizeof know array size?
Explain what are header files and explain what are its uses in c programming?
What are the uses of a pointer?
Can you please explain the scope of static variables?
What is structure data type in c?
Explain is it valid to address one element beyond the end of an array?
Write a program to generate random numbers in c?