Circular Sum Question in array sectio

code for max circular sum using kadane’s algorithm and rotating subarray by brute force in the loop…

#include
using namespace std;

int main() {
int t;
cin>>t;
for(int i=0;i<t;i++){int n;
cin>>n;
int a[n];
int curr=0;
int max=0;
for(int j=0;j<n;j++){
for(int k=0;k<n-1;k++)
{ int num=a[n-1]; //circlar rotation of array
a[k+1]=a[k];
a[0]=num;
curr=0;

    for(int h=0;h<n;h++) //Kedane's Algo
    {curr+=a[h];
    if(curr<0)
    curr=0;
    if(curr>max)
    max=curr;
    }
    
  }
}
cout<<max<<endl;

}
return 0;
}

Why is maximum a garbage value???

Code @ https://ide.codingblocks.com/s/61994

https://ide.codingblocks.com/s/61994

because you have not taken the array from user

Hey Manoj, as you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.

Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.