Help me in solving SNDMAX problem

My issue

My code

#include <stdio.h>

int main(void) {
	// your code goes here
	int t;
	int arr[100];
	int i,j,k;
	scanf("%d",&t);
	
	for(i=0;i<t;i++)
	{
	    for(j=0;i<t;j++)
	    {
	        scanf("%d",&arr[j]);
	    }
	    for(i=0;i<t-1;i++)
	    {
	        for(j=1;j<t;j++)
	        {
	            if(arr[i]<arr[j])
	            {
	                k=arr[i];
	                arr[i]=arr[j];
	                arr[j]=k;
	            }
	        }
	    }
	   printf("%d\n",arr[1]);
	}
	return 0;
}


Problem Link: SNDMAX Problem - CodeChef

@ajay0191

Here is an error in your code;

for(j=0;i<t;j++)

While taking inputs, instead of using j, you have used i in middle which might be causing issues.

The correct one should be the following.

for(j=0;j<t;j++)

include
using namespace std;

int main() {
int t;
cin >>t;
while(t–){

        int a,b,c;
            cin >>a>>b>>c;
            if (a<b){
                if (b<c){ 
                    cout<<b<<endl; 
                }
                
                else if(a<c){
                    cout<<c<<endl; 
                }
                else{
                    cout<<a<<endl;
                }
            
        }  
}    

	return 0;

}