Robot Travel

hey what bug in my code on submitting the codechef judge says wrong answer and here is the problems [link].1


program SMCD6;

uses Math;

var
<var>   T,A,B,M</var>:longint;
   
begin
	
	read(T);
	
	while T <> 0 do
	begin
	
	read(A,B,M);
	if abs(B-A) = M then writeln(0)
	else writeln(abs(B-A) div M);

	T := T-1;
	end;
	
end.

you can see the code in c++ to but by other user here it is


#include <iostream>
using namespace std;

int main(){
	int t = 0;
	cin >> t;
	while(t--){
		int a,b,m = 0;
		cin >> a;cin >> b;cin >> m;
		cout << (b-a)/m << endl ;		
	}
	return 0;
}

hey here is my C(gcc 4.9.2) code which perfectly works so what wrong with the pascal FPC code

Here is c codeā€¦


#include <stdio.h>
#include <math.h>

int main(void) {
	int T=0;
	
	scanf("%d",&T);
	
	while(T--){
	    int A=0,B=0,M=0;
	    scanf("%d%d%d",&A,&B,&M);
	    printf("%d\n",(B-A)/M);
	    
	}
	
	return 0;
}



Hey i have founded the bug the correct code is this


program SMCD6;

uses Math;

var
   T,A,B,M:longint;
   
begin
	
	T := 0;
	read(T);
	
	while T <> 0 do
	begin
	
	A := 0;B := 0;M := 0;   
	read(A,B,M);
	writeln(abs(B-A) div M);

	T := T-1;
	end;
	
end.


//