Help me in solving CODEBU13 problem

My issue

My code

#include <iostream>
using namespace std;

int main() {
    int t;
    cin>>t;
    while(t--)
    {
int n,k;
cin>>k>>n;
double res= 1;
int i=1;
while(i<=k)
{
    res=res*(n-k+i)/i;
    
}
cout<<res<<endl;
}

	return 0;
}

Problem Link: CODEBU13 Problem - CodeChef

There is an improved code with corrections :

#include <iostream>
using namespace std;

int main() {
    int t;
    cin>>t;
    while(t--)
    {
int n,k;
cin>>n>>k;    // Here you took wrong input .
int res= 1;
int i=1;
while(i<k)
{
    res=res*(n-k+i)/i;
    i++;   // You forgot increment of i, hence the value of i was same whole time.
    
}
cout<<res<<endl;
}

	return 0;
}

Hope, these two changes will correct the code.:slight_smile: