+ 2

why z value is 12? explain me pls

//here is my code.. pls tell me #include<iostream> using namespace std; int main() { int x,y,z; x=12; y=24; z=x%y; cout<<"Value of z is" <<z; return 0; }

24th Jun 2017, 10:26 PM
Md. Rabbi Al Mamun
Md. Rabbi Al Mamun - avatar
8 odpowiedzi
+ 5
Z is 12 because when 12 goes into 24, the remainder is still 12
24th Jun 2017, 10:28 PM
Nomeh Uchenna Gabriel
Nomeh Uchenna Gabriel - avatar
+ 3
When x is lower than y, the intuition should be: 'x' fits exactly *zero* times into 'y' and there is still a 'y' remainder left :)
25th Jun 2017, 6:06 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 2
:/
24th Jun 2017, 10:30 PM
Md. Rabbi Al Mamun
Md. Rabbi Al Mamun - avatar
+ 2
from modulus in math since your X is lower than the y and the output is an integer, therefore your X would be the remainder because no division occurred. try exchanging X with a number lower than y and you would get X as the remainder and output.
25th Jun 2017, 10:41 PM
Sammy
Sammy - avatar
+ 2
Thanks @sammy
26th Jun 2017, 12:31 AM
Md. Rabbi Al Mamun
Md. Rabbi Al Mamun - avatar
+ 2
You are welcome Rabbi
28th Jun 2017, 5:26 PM
Sammy
Sammy - avatar
+ 1
oh...now understand brother... thanks :)
24th Jun 2017, 10:32 PM
Md. Rabbi Al Mamun
Md. Rabbi Al Mamun - avatar
0
thanks @kuba_bro :)
25th Jun 2017, 7:44 AM
Md. Rabbi Al Mamun
Md. Rabbi Al Mamun - avatar