Beginner C++ class HW confusing answer

In the following code below, i am asked what will print on the screen in the question, i guessed it would display 23 and below on a new line 11.5 cause that's 23 / 2. Then i remembered that integers are only whole numbers so i decided to build and run anyways and it gave me, 23 and below it 1. Why did it give me the 1 ?

1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
using namespace std;
int main()
{
	int a, b = 23;
	a = b % 2;
	cout << b << endl << a << endl;
	system("pause");
	return 0;

}
Last edited on
% is modulo (remainder) not divide
Thanks man, wow i feel dumb I'll read more carefully from now on
Topic archived. No new replies allowed.