Don't know about how to take input for multiple test cases

I don’t know how to take input for multiple test cases. So I kindly request you to teach me how to take the same.

hello @atreyyash

for such type of questions , u just have to repeat ur logic for t new input.

so all such problems will have this template

read number of test cases (say t)

for(int i=1;i<=t ;i++ ) {  // iterate for t times for t new inputs 

read input 

apply ur logic on given input

print output

}

But my ques says that input for all test cases should be entered in the begining

which question pls share it with me

if u r talking about this
image

then above template will work fine

read t , and then iterate from 1 to t .
and in each iteration read size of array and then array elements and then output ur answer

Maximum Subarray sum. I have written the code for this and it is giving right answer for first test case but does not run for further cases. this is my code :: https://ide.codingblocks.com/s/429676

declare all ur variables that are part of ur logic inside the for loop .

also note that ur inner and outer loop are using same variable name i.
so change one of them

check this-

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.