why the result of the follow code is zero?

Shouldn't it be 23? Thanks!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
// trying to compute the division of two integers in c++
#include<iostream>
using namespace std;
 
 int main(){
 int i = 234;
 int j = 10;
 int p = j/i;
 cout << p << endl;
 
 
 return 0;
 }
Some compilers truncate, which would result in 23. Others have undefined behaviour.
j = 10, i = 234, j/i = 10/234 = 0
Oh, yeah. That, too.
LOL. Sorry, I am just a daft prick.
Topic archived. No new replies allowed.