Learning course: Arrays using C
Problem Link: CodeChef: Practical coding for everyone
Feedback
For the below written code I am getting the desired output for the first case but for the remaining cases, I am getting random outputs, please help me understand what’s going wrong here, I am not able to find the particular reason for such behaviour of my code.
code:
include <stdio.h>
int main(void) {
int t,n,c;
scanf("%d",&t);
for(int i=0;i<t;i++){
c=0;
scanf("%d",&n);
int a[n],b[n];
for(int j=0;j<n;j++) scanf("%d",&a[j]);
for(int j=0;j<=n;j++) scanf("%d",&b[j]);
for(int k=0;k<n;k++){
if(a[k]<=2*b[k] && b[k]<=2*a[k]){
c++;
}
}
printf("%d\n",c);
}
return 0;
}