Posts

Showing posts with the label 1)cheak sorted area 2)find frst &lst pstn 3)wrt nmbr in Inc& dec odr

Use of Recursion

Image
//cheak sorted array or not #include<iostream> using namespace std; bool check(int arr[],int n) {   if (arr[n-2]==arr[0])         {return 1;}     if(arr[n-1]>arr[n-2])        { return check(arr,n-1) ;}   else{ return 0;} } // write the sequence of decnbr void decnmbr (int n) {     cout<<n<<" ";    if(n==0){return;}    decnmbr(n-1);    } // find first occurance int firstoccurance (int a[],int n,int key,int i) {     if(i>n)      {return -1;}     if(a[i]==key)         {return i;}         firstoccurance( a,n,key,i+1);                    }   //find last occurrence...