Sir what the mistake am i doing?

Modified Code

Your Mistakes

  1. forgot to take q as input
  2. also define the size of array
    int arr[n] not correct
    because n will be get at runtime but array will be declare at compile time

Correct
int arr[100000];

a[100000] ko define krna, isase a[n] kam time leta hai kya ?

No, n is garbage initially
so anything my happen

okay sir, thank you done …

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.