+ 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; }
8 Antworten
+ 5
Z is 12 because when 12 goes into 24, the remainder is still 12
+ 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 :)
+ 2
:/
+ 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.
+ 2
Thanks @sammy
+ 2
You are welcome Rabbi
+ 1
oh...now understand brother... thanks :)
0
thanks @kuba_bro :)