I think the code is running infinity times as there is no checking condition
when to stop the calculation of max value. so before going to the max
function there should be a checking till when you need to run the loop.

Regards,
Durga

On Tue, Aug 2, 2011 at 2:30 PM, Gayathri Anandan <
[email protected]> wrote:

> I didnt get any output for this pgm. I think its keep on running and
> got struck in the 6th line. Plz help with this.
>
> 1 #include<stdio.h>
> 2 #include<conio.h>
> 3 int max(int a[10],int s,int e)
> 4 {
> 5 int res,res1,res2,mid=(s+e-1)/2;
> 6 res1=max(a,s,mid+1);
> 7 res2=max(a,mid+1,e);
> 8 res=res1>res2?res1:res2;
> 9 return res;
> 10 }
> void main()
> {
> int a[]={2,4,1,2,3,8,7,6,9},maxval;
> maxval=max(a,0,9);
> printf("%d",maxval);
> getch();
> }
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to