My issue
include <stdio.h>
int main() {
// your code goes here
int t;
scanf(“%d”,&t);
while(t–)
{
int n;
scanf(“%d”,&n);
int a[n];
for(int i =0;i < n;i++)
{
scanf(“%d”,&a[i]);
}
int max = a[0];
for(int i =0;i<n;i++)
{
if(max<a[i])
{
max = a[i];
}
}
printf("%d",max);
}
}
what is wrong in above code why it is saying “Failed on a Hidden Case”
My code
#include <stdio.h>
int main() {
// your code goes here
int t;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
int a[n];
for(int i =0;i < n;i++)
{
scanf("%d",&a[i]);
}
int max = a[0];
for(int i =0;i<n;i++)
{
if(max<a[i])
{
max = a[i];
}
}
printf("%d",max);
}
}
Learning course: Data Structures & Algorithms using C
Problem Link: Find maximum in an Array in Data Structures & Algorithms using C