I DIDN'T GET THE FUCKING JOB BECAUSE I DON'T KNOW WHAT MODULO IS
Here's the answer I gave, it fucking works so what is the problem?
void isEven() {
double x;
for (double i = 0; i < 100; i++) {
if ((x = i/2) && (int)x == x)
std::cout
I DIDN'T GET THE FUCKING JOB BECAUSE I DON'T KNOW WHAT MODULO IS
Here's the answer I gave, it fucking works so what is the problem?
void isEven() {
double x;
for (double i = 0; i < 100; i++) {
if ((x = i/2) && (int)x == x)
std::cout
Modulo is a meme
>I DON'T KNOW WHAT MODULO IS
The absolute S T A T E of webdevs
Mod is practically the same as getting the remainder after dividing.
You dumb shit, you could have just fucking googled it.
modulo is slow
This. Depending on the language and use case, 99% of the time you'd benefit from implementing your own routine @byte-level
This isn't even valid code.
C doesn't have a guaranteed order of evaluation, so the side effects could happen at any time before the next statement.
This code gives UB.
And even if it works in practice, it's slower.
Suggest applying for a New Delhi helpdesk gig as a career starting point.
Over-engineer your own pathetic side projects instead, either learn what businesses actually want from a programmer or shut the fuck up about how amazing you are.
People like you are fucking nightmares to work with. Now go cry and masturbate at the same time about how underappreciated you are.
>google as a verb
It could be he doesn't know the definition of it because wasn't taught math in English.
or... you do not even need to know modulo.
(x&1) == 0)
Well he should know it lmao if hes gonna go apply for a serious job anywhere
>perse as a pronoun
>C doesn't have a guaranteed order of evaluation
wrong
in general it does not, but it specifically does have guaranteed order for &&, ||, ?, and , (comma)
It may be slow but it is never going to slow your code down in any meaningful level in a practical application.
If your code will ever be read by another human, don't obfuscate your code with custom functions that get barely any noticeable gain, dumbass.
Lol needing doubles for this logic
Deserved.
Every programmer should know what modulo is. literally Programming 101
Even if you didn't know modulo somehow (I would never hire someone who doesn't know such a fucking basic operation), you can very easily make an O(1) modulo function. Checking if even is by far even simpler.
You could have done ((n&1)==0), (((n/2)*2)==n), (((n)
Man, I feel dumb. I did this nonsense,
x / 2 == x >> 1
but your answer makes so much more sense.
>Didn't know what modulo is.
I wouldn't hire you either, you'll find a retarded and inefficient way to do everything because you don't know the basics.
>what is the problem?
they didn't want you
>function is called isEven, returns void
>function takes no parameter to check if its even
>double x
>for loop to 100
>divide by 2
>useless cast
>std::cout
This is a carefully crafted bait I guess
Don't forget double i
It needs to be double, C is outputting in half of a loop.
what is the the point of assigning x in the if statement instead of in the line before it?
you didnt know what's a modulo
i remember learning abt that in 7th grade lel
the program never halts mate so no it doesnt even work dingus
No, it's constant time. For all intents and purposes, just as fast as any other operation.
Should have just done a bitwise check of the last bit in variable i.
Not if it is modulo 2 as in the OP. Compiler optimizations, newfriend
>(x = i/2)
Returns 0 (false) for i==0, right? So your solution does not work. If I saw this code I wouldn't have given you the job either
>posts a statement without proof
Get % retards lol
>No, it's constant time.
wrong
Is this bait?
>Returns 0 (false) for i==0, right?
This is true.
Learning modulo is one of the basic parts of learning mathematical notations in programming. I imagine that a large number of people skip it because they think "what do I need math for" but basic mathematical equations are so important for any programming that if you don't know how to do them in the language of your choice you're basically worthless.
>The absolute S T A T E of webdevs
>C++ answer
>Assumes webdev
In most cases this is already implemented in the compiler. In C# you can also use pointer but it's usually slower because the compiler doesn't optimize as much as without.
It is correct. For any given data type on the left side of the operator, there is an upper limit on how long modulo can take to finish, which is referred to as "constant time" in complexity theory. And there are only finitely many basic data types which can be used on the left hand side of the modulo operator
Okay prove me wrong you retards.
Here's a solution that actually works and doens't break.
Reinventing the wheel with unreadable code.
Here's what I'd do:
bool isEven(int n) {
return (1 & n) == 0;
}
You should have made it interactive, ie:
>0 is even, is this the even number you were looking for? [y/n]
$ n
>2 is also even, is this the even number you were looking for? [y/n]
$ n
>4 is also even, is this the even number you were looking for? [y/n]
$ n
>6 is also even, is this the even number you were looking for? [y/n]
$ y
kek
most people on Jow Forums don't know how to code and you replied to a retarded tech illiterate (he
s probably a zoomer too)
DAMM Javscript looks like THAT?
>I DIDN'T GET THE FUCKING JOB BECAUSE I DON'T KNOW WHAT MODULO IS
How do you not know what modulo is when applying for a programming position? It’s like not knowing how to write an inline conditional statement.
>double
Literally high school math.
Is this actually a thing? I work with a lot of people who could be considered webdevs and I'm almost a 100% sure all of them know what a modulo is.
void isEven() {
for (int i = 0; i < 100; i += 2) {
std::cout
Hahahaha you dumb fucking frog!
>I DIDN'T GET THE FUCKING JOB BECAUSE I DON'T KNOW WHAT MODULO IS
Good.
>not knowing how to write an inline conditional statement.
Is that like x = i < 2 ? ifTrue : ifFalse
T. Zoomer learning c++