Write a c program to search an element in an array using
recursion
Answer / lel
#include<stdio.h>
#include<conio.h>
void search(int a[], int k, int n, int j);
int main()
{
int a[12],i,k,j=0,n;
printf("Enter the no. of ele : \n");
scanf("%d",&n);
printf("Enter the ele\n");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("Enter the ele you want to search : \n");
scanf("%d",&k);
search(a,k,n,j);
getch();
return 0;
}
void search(int a[], int k, int n, int j)
{
if(j<n)
{
if(k==a[j])
{
printf("The ele is present. It is %d at a[%d]",a[j],j);
}
else
{
search(a,k,n,j+1);
}
}
else
printf("The ele you are searching for is not present !!");
}
| Is This Answer Correct ? | 7 Yes | 2 No |
how to create a 3x3 two dimensional array that will give you the sums on the left and bottom columns
how can i search an element in an array
2 Answers CTS, Microsoft, ViPrak,
int main() { int x=10; printf("x=%d, count of earlier print=%d", x,printf("x=%d, y=%d",x,--x)); getch(); } ================================================== returns error>> ld returned 1 exit status =================================================== Does it have something to do with printf() inside another printf().
Sir... please give some important coding questions asked by product companies..
#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }
main() { char *p; p="%d\n"; p++; p++; printf(p-2,300); }
How can i find first 5 natural Numbers without using any loop in c language????????
void main() { if(~0 == (unsigned int)-1) printf(“You can answer this if you know how values are represented in memory”); }
#include<stdio.h> void fun(int); int main() { int a; a=3; fun(a); printf("\n"); return 0; } void fun(int i) { if(n>0) { fun(--n); printf("%d",n); fun(--n); } } the answer is 0 1 2 0..someone explain how the code is executed..?
main() { signed int bit=512, i=5; for(;i;i--) { printf("%d\n", bit >> (i - (i -1))); } } a. 512, 256, 0, 0, 0 b. 256, 256, 0, 0, 0 c. 512, 512, 512, 512, 512 d. 256, 256, 256, 256, 256
program to Reverse a linked list
12 Answers Aricent, Microsoft, Ness Technologies,
WAP to display 1,2,3,4,5........N