Your interviewer asks you what this piece of code does and why it's a good thing to run on CPUs and RAM...

Your interviewer asks you what this piece of code does and why it's a good thing to run on CPUs and RAM. What is your response?

Let's see if anyone on Sup Forums has a job because if you can't read and understand this simple piece of code, you will never get a decent job.

I'd tell him to do his wife's son's homework himself and then turn 360 degrees and walk way

I got the job simply by getting dubz, as I'm about to show you right now.

Pathetic, I'm powered by the singles. The doubles only increase my extremeness, witness my digits

It's a waste of time is what the code is. There's no reason to run it.

360 degrees and you still looking toward him you mongoloid

t. brainlet NEET

t. unemployed

I can read it and understand it. I'm just not doing your homework

newfag

I know what the code is doing, it's just a waste of time.

There's no benefit to be running it, so it's not "a good thing to run on CPUs and RAM".

It figures out the max alloc size possible right?

do your own homework.

>if you are not pajeet codemonkey, you are unemployed

Even if you can't answer the OP, you'd be stupid to take what he says to heart.

"Is that your final answer" - inrerviewer

idk

probably dubs threads can't get because the gpu can only do single precision, so no dubs_get()

>notice stdafx.h
>get up and leave

Lol

>Sup Forums can't pass a simple interview

lsl

nigga i get paid 25k a year copy pasting code from stack overflow

It doesn't do much of anything. Just some prints, and mallocs some space for a while, but its not modified

it doesn't display anything because x = 0. but it's a good thing to run on cpu and ram because it shows how much memory is available

>int x = 0;
...
>return x;

This code is so fucking shit. Did you write it yoruself?

>casting the return value of malloc()
Stand up and leave the interview.

Think about what he said. Turn 360 degrees, aka an Pirouette, and THEN he walks away.

>Using windows to compile C code
kys

How would you tell?

t. curious guy

I don't know C.

>casting malloc
huh??

I-I applied for the machine learning engineer role where are the data

It doesn't though.

You have to input the memory space it will use, it will attempt to allocate that amount of memory, if it fails then it dumps out. If it succeeds then it just runs repeat * 1000000 loops and then frees the memory and dumps out.

It's not doing shit. It's just wasting time.

Tell him that his unvalidated atoi call could lead to an int overflow.

Also, this:

>calling malloc with command line arguments
what a fucking retard

it does nothing useful and returns 0, that's what it does

>casting malloc
CEASE

It creates an array then increments every 16th element of it, when it reaches the end it wraps around.
>it's a good thing to run on CPUs and RAM
As opposed to what? Running on eggs and ham?

>7-space indents
what the fuck

It's a trick question. What the code does should be provided in the documentation.

does it simply benchmark memory access by accessing every 16 elements in the array a million times and repeat that the given number of times and report the sum, starting over from the first element if it rolls over the end of the array?

I see no other reason than benchmarking to run this

jesus fucking christ pick a parenthesis styling guide and stick to it.

Do one or the other but not both you heathen

>please Sup Forums do my homework!

>index -= areasize
This code shows that its author is a fucking idiot.
stdafx

I bet someone from Sup Forums used this line to an interviewer.

I thought that was K&R. Newline on opening bracket for functions but not if statements or loops.

>working in the tech industry
ONE MILLION KEKS. I would never step foot in this industry user. I have standards you know

K&R is shit style though

>why it's a good thing to run on CPUs and RAM.
it is NOT.

/thread

t. NEET

>trying to defend your shitty code by calling anyone who says that it is shit unemployed

No, we aren't going to tell you how to fix it either. It's doing a perfectly good job at being useless.

You realize the code is publically available for everyone and it works but it's a terrible written code.

>making minimum wage

this
Fuck winblows

"Works" is a very loose term.
Does it compile and run? Sure.
Does it do what the author intended? Probably not.

>areasize = (kb * 1024) / sizeof(int)
...
>area = malloc(areasize * sizeof(int))
stopped reading right there

Garbage code, someone needs a linter and why the fuck are you using malloc? Any open source code base scanner will tell you that is fucking dumb.

I can only assume that he is trying to prevent overflows, but I would have thought that malloc would overflow anyway.

>what this piece of code does
fucking nothing

alright I'll be that guy, what does it do?

It looks like it mallocs an array of ints, then increments every 16th int, then wraps around

Not sure why this piece of shit does it 1 million times or why it only increments every 16th

Gives you good grades in school for a correct answer

With -O3 it would probably exit immediately.

>"Finished reading!\n"
nigga, finished reading what?
The more I look at this the worse I feel. Is that what this is supposed to do? Make me feel bad?

every 512 bits treat 32 bits as an integer and increment by 1000000, then delete everything

I have absolutely no clue. might be a new encryption scheme. I bet the nsa will take ages to figure that one out.

apologies, I am mistaken. 62500 / areasize. not 1000000

>that include order
>using atof and atoi
enjoy your unhandled errors
>printing error messages to stdout
that's what stderr is for
>#define in middle of source code
just why
the index overflow doesn't work when areasize is smaller than half of STEP, use modulo

Overall it does nothing, the only thing it returns is exit value 0/1 and few meaningless strings. It really just wastes CPU and RAM.

Lurk more newfag. Don't ever let me see you posting here again

>suffering from terminal autism
huh... life must be tough

>t. NEET
No, I am a university student, but my Processor and RAM is too valuable for me to run your shitty code on.

Quality code, OP

...

#include
#include

void
main()
{
char *s = "gas OP";
uchar *area;

area = malloc(sizeof s);
if(area == nil)
exits("आप यह अफसोस करने के लिए रहते हैं");
memcpy(area, s, sizeof s);
free(area);
exits(nil);
}

>#include
>#include

/thread

rabbit you are my strongest ally

You need to do so if you want to compile with a C++ compiler.

>compiling c with c++ compiler
why

What is that even supposed to do? Store memory in a CPU and RAM and then get rid of it? For what fucking purpose?

>and why it's a good thing to run on CPUs and RAM.
is there supposed to be some other way to run it?

What else could he use if not malloc? Direct system calls?

>using malloc
deprecated code

fucking amateur

do your own homework cs pajeet

I would wonder how the interviewer himself got his job.

kek well said

Also this code has a bug in it too

It does nothing, really, as far as the user is concerned. But if you want to be pedantic, what it does to the RAM it uses is quite simple, it keeps incrementing every STEP long, wrapping the index around when it reaches the end. If "area" size is a multiple of STEP, the same elements are incremented each time. If not, it swifts according to the modulo of the two values.

>why it's a good thing to run on CPUs and RAM. What is your response?
This is the kind if question asked by people who define "their" way of doing things as the right way. This code might be a useful way to do benchmark ram, but useful and good are two separate things.

>being this new

>code monkeys