C Program For Linear Recursion

#include<stdio.h>
#include<conio.h>
int a[5];
int linear(int num,int position)
{
if(num==a[position])
 {
return position;
 }
 else
 {
position++;
return linear(num,position);
 }
}
 void main()
 {
int i,n,ans;
clrscr();
printf("Enter The Numer Of Elements");
scanf("%d",&n);
printf("Enter array elements:");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("Enter the number to be searched");
scanf("%d",&n);
ans=linear(n,0);
if(ans<=n)
 {
printf("number (%d) found at position (%d)",n,ans++);
 }
 else
 {
 printf("search element (%d) not found ",n);
 }
 getch();
 }
Bhanu Namikaze

Bhanu Namikaze is an Ethical Hacker, Web Developer, Student and Mechanical Engineer. He Enjoys writing articles, Blogging, Solving Errors and Social Networking. Feel Free to let me know any of your concerns about hacking or let me know if you need any more methods on hacking anything. Enjoy Learning

No comments:

Post a Comment