У меня есть этот фрагмент:
#include <stdio.h>
#include<conio.h>
void main() {
int x = 10/0;
printf("%d", x);
getch();
}
Выше приведен вывод 10
.
Но если я запусту это:
#include<stdio.h>
#include<conio.h>
void main() {
int x = 10/2;
printf("%d", x);
getch();
}
Вывод будет 5
.Почему?
Я использую TurboC++
компилятор для Windows 7
, используя DosBox
.
Также, если я делаю так:
#include<stdio.h>
#include<conio.h>
void main(){
int x=10;
x=x/0; //now it would not compile and gives error
}