Generating subarrays

what will we do if we want to print the subarray with specific no of elements
like an array has 5 elements and we want to print that subarrays which have only 2 elements

@utkarsh2504 here refer this


dont forget to mark the doubt resolved and hit like if cleared :smiley:

thnx that worked if we want the sum of these subarrays will we use another loop and initialize sum at the start of it?

@utkarsh2504 same code just instead of printing calculate sum and print it and initialize 0 to it again

i initialized it with the first element of the subarray was not getting the correct answer with sum=0;

@utkarsh2504 tell me what you want to do?