0

hey i got a problem while taking inputs from user recently i wrote coding question in hackerrank in that it ask like first line contains no of test cases and second line (next N lines) contains no of inputs like for eg

 2(test cases)
    7
    11

for this i wrote code like this

int n=sc.nextInt();
for(int i=0;i<n;i++)
{
int p=sc.nextInt();
}

hope u understand the problem like how should i store each value in sperate variable here 7 is stored in p variable then i didn't understand like how to store 11 in seperate variable or any other solutions are available?

5
  • this is a java question, not a c question. Please remove the c tag Commented Apr 29, 2019 at 7:37
  • Suggest implementing an array for variable 'p' Then index into that array via variable 'i' Commented Apr 29, 2019 at 7:38
  • without using array is that possible? Commented Apr 29, 2019 at 10:28
  • Give your variables proper names. Why do you need to store those values? Why would you rather not use an array? If you just need to generate that output why not do it in the loop? Generally coding quests are out of scope on SU and rather belong on StackOverflow.
    – Seth
    Commented Apr 29, 2019 at 11:20
  • without using array is that possible Yes, anything is possible, However, being practical would involve an array Commented Apr 29, 2019 at 13:33

0

You must log in to answer this question.

Browse other questions tagged .