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 are pointers declared in c?
What is the sizeof () a pointer?
Is javascript written in c?
How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same
Explain void pointer?
How can I direct output to the printer?
What are the types of type specifiers?
Write a program to reverse a given number in c language?
Describe wild pointers in c?
count = 0; for (i = 1;i < = 10; i++);count = count + i; Value of count after execution of the above statements will be a) 0 b) 11 c) 55 d) array
What is c variable?
What does d mean?
Is struct oop?
Do variables need to be initialized?
Is c is a high level language?