Help me in solving FIT problem

My issue

find the error

My code

#include <stdio.h>

int main(void) {
	// your code goes here
	int T,X,i,distance;
	scanf("%d",&T);
	for(i=0; i<T; i++){
	    scanf("%d",&X);
	    if(X==5){
	        distance=2*X;
	        printf("%d",distance);
	    }
	
	    }
	}
	return 0;
}


Learning course: Basic Math using C
Problem Link: Practice Problem in - CodeChef

1 Like

@kalpanabhati
I have corrected your code
hope u will get it

#include <stdio.h>

int main(void) {
	// your code goes here
	int T,X,i,distance;
	scanf("%d",&T);
	for(i=0; i<T; i++){
	    scanf("%d",&X);
	        distance=10*X;
	        printf("%d\n",distance);
	
	    }
}

you forgot to run a loop for test case & the condition you are applying (x==5) is wrong, actually you are not able to understand the question

solution :-

include <stdio.h>

int main(){
int t;
scanf(“%d”,&t);
while(t–){
int x; //the given distance
scanf(“%d”,&x);
printf(“%d\n”,2x5);
// because he walk home to office & he returns office to home to total distance
//he walk a day is 2x & he go office 5 day a week i.e 2x*5
}
return 0;
}

1 Like