Computer Science, asked by Shinushree4612, 11 months ago

Find the smallest number in an array using recursion in c

Answers

Answered by Anonymous
0
5 Answers

order by                          active                         oldest                         votes                     

up vote0down voteaccepted

Here is simple code for finding minimum value using recursion,

int rec(int a[],int n) { int min; if(n==1) return a[0]; else { min=rec(a,n-1); if(min<a[n-1]) return min; else return a[n-1]; } } void main() { int i,j,n,a[20]; printf("enter n :"); scanf("%d",&n); printf("enter values : "); for(i=0;i<n;i++) { scanf("%d",&a[i]); } printf("\n%d",rec(a,n)); getch(); }

I hope the answer is clear
If you like it follow me
Pls mark me as brainlist
#Nisha
Similar questions