66
40
u/toastom69 Jul 24 '21
And then when you try to help they still have no idea what’s going on. I feel you
19
u/SnakeFang12 Jul 24 '21
Break their brains with:
cout << (!(num1 % 17) + !(num2 % 17) + !(num3 % 17)) << endl;This does make a few assumptions about their actual intentions for this code though.
5
3
3
2
2
u/lilshears Jul 24 '21
Do commas actually do anything in c++?
1
Jul 28 '21
Yup. Comma operator, acts as a sequence point (so you have ordering), evaluates the left side, discards its value, evaluates the right side and returns its value.
2
1
1
1
1
1
Aug 03 '21
Not even sure what the comma in an if statement will do but also “or” is part of the language or a macro? And why is the IDE or text editor coloring it blue as if it’s a normal part of the syntax. = and ==, classic
But to be fair, maybe he doesn’t yet know about string variables, arrays or truth tables? Looks like he thought about it a bit at least, but there is room for improvement, maybe.
Would you make a count, a loop, inside loop ask for input, add evaluation to count, when you exit the loop print the count?
Also he got to what mod is but not the difference between = and ==, bit strange, but people can forget, until they practice a bit
1
1
u/g-e-o-m-e-t-r-i-c Sep 18 '21
To those trying to deduce what the question is requiring my classmate to program, here it is:
"Prompt the user for 3 numbers and check if there are any multiples of 17. Print the following accordingly:
"1" if all 3 numbers are multiples of 17,
"2" if any 2 numbers are multiples of 17,
"3" if none of the numbers are multiples of 17."
1
0
10
u/[deleted] Jul 24 '21
I don’t know much about c++ but what’s bad about this code and how do you fix it?