In the following two codes I cannot understand the problem. First code is:
#include <stdio.h>
main() {
int num1, num2;
scanf("%d%d", &num1, &num2);
printf("I LOVE MY INDIA\n"); //here is '\n' after the statement
printf("%d", num1/num2);
return 0;
}
Here if the inputs are num1=2
and num2=0
then in gcc compiler the output is:
I LOVE MY INDIA
Floating point exception (core dumped)
But for the second code:
#include <stdio.h>
main() {
int num1, num2;
scanf("%d%d", &num1, &num2);
printf("I LOVE MY INDIA"); //here is no '\n'
printf("%d", num1/num2);
return 0;
}
For same input as before this is showing:
Floating point exception (core dumped)
In between these two codes there is only one difference. In the 1st one there is a \n
after I LOVE MY INDIA
and in the 2nd code there is no \n
.
Please explain why I LOVE MY INDIA
is not being displayed in the 2nd code.