Question description Sathya is a IT expert who training youngsters struggling in coding to make them better. Sathya usually gives interesting problems to the youngsters to make them love the coding. One such day Sathya provided the youngsters to solve that the given an array of integers and the numbers k1 and k2, get the sum of the two numbers. Find the sum of all elements in the array between the k1st and k2nd smallest elements
C Program


#include<stdio.h>

int main()

{

int t;

scanf("%d",&t);

while(t>0)

{

int n;

scanf("%d",&n);

int a[100],i,temp;

for(int i=0;i<n;i++)

scanf("%d",&a[i]);

for(int i=0;i<n-1;i++)

for(int j=i+1;j<n;j++)

if(a[i]>a[j])

{

temp=a[i];

a[i]=a[j];

a[j]=temp;

}

int k1,k2,sum=0;

scanf("%d %d",&k1,&k2);

for(i=k1;i<k2-1;i++)

sum+=a[i];

printf("%d\n",sum);

t--;

}

return 0;

}