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

What is string length in c?

615


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

1481


Which is the memory area not included in C program? give the reason

1509


Write a program to know whether the input number is an armstrong number.

674


What is void c?

569






How to Throw some light on the splay trees?

621


number of times a digit is present in a number

1544


What is function in c with example?

631


Which is the best website to learn c programming?

584


Why is c so powerful?

687


What are the types of functions in c?

576


What is default value of global variable in c?

564


What are the advantages of using Unions?

642


What are volatile variables in c?

522


What do you understand by normalization of pointers?

627