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
What is string length in c?
i want to switch my career from quailty assurance engineering to development kindly guide me from which programming language its better for me to start plz refer some courses or certifications too i have an experience of 1.5 yrs in QA field.Kindly guide me
Which is the memory area not included in C program? give the reason
Write a program to know whether the input number is an armstrong number.
What is void c?
How to Throw some light on the splay trees?
number of times a digit is present in a number
What is function in c with example?
Which is the best website to learn c programming?
Why is c so powerful?
What are the types of functions in c?
What is default value of global variable in c?
What are the advantages of using Unions?
What are volatile variables in c?
What do you understand by normalization of pointers?