0

Please tell why this solution is not acceptable by dcoder

this is the program to print the fraction in .C #include <stdio.h> //Compiler version gcc 6.3.0 int main(void) { int i,j; int N,D,a,b; scanf("%d%d",&N,&D); if(1<N<D && 1<D<1000) { for(i=1; i<=1000;i++) { if(N%j==0&&D%j==0) { a=N/j; b=N/j; } else { printf(" false"); } } } printf("The Fraction : %d/%d",a,b); return 0; } why is it not getting output??

23rd Mar 2019, 3:30 AM
OMKAR SAWANT
OMKAR SAWANT - avatar
2 odpowiedzi
+ 7
"Why is it not getting output" question are only answerable if you put a link to a working example or give the whole error message
23rd Mar 2019, 3:37 AM
Letsintegreat
Letsintegreat - avatar
+ 5
In your code, you never initialize j, which probably stores some garbage value. But you use it to perform some calculations. This can lead to unwanted behaviour. The solution is to simply provide a default value for j, such as 1, and modify it if required later in the program.
23rd Mar 2019, 3:41 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar