tfw just got my engineering midterm back

> tfw just got my engineering midterm back
> tfw only got a 75%
> tfw did great on everything but the loops and conditionals


am I just a brainlet or is it pretty ridiculous for my professor to test us on super confusing and pointless nested loops? who the fuck would ever make an actual code like this?


im pretty most of the class failed this part too...

What was the question?

brainlet

Why would it be "no output"?
I know it's a trick question, but the outer loop will only have 1 iteration before j > 0 is false, so you can figure out both values of k because that loop will only execute twice.

>Why would it be "no output"?
>I know it's a trick question, but the outer loop will only have 1 iteration before j > 0 is false, so you can figure out both values of k because that loop will only execute twice.

The outer loop runs twice dumb fuck

Oh i wouldn't know.
I can't imagine why anyone would write some shit code like this unless they're trying to make themselves unfireable.

>multiple choice
>online
what a joke

>
>Oh i wouldn't know.
They why are you fucking commenting?

There's no outer loop, dumbass. There is a loop that sets j=0 and the loop that prints, which ends up having one iteration.

what will print

it was in class and the computers were set up to only display the quiz so its not like I could just go to codeblocks to see what would print... unless I wanted to get a zero for cheating...


idk I thought you needed braces for nested loops I didnt realize it was a trick question

It's still multiple choice on a coding exam, which is an absolute joke

that first loop has a semicolon for some reason.

what a retarded question.

>tfw running code is cheating
like wtf is this. it's 21st century. people doesnt compile and run program in their head anymore

Is this question a joke?

hahah

I like to imagine that I would have gotten this one right, and the teacher would have marked me wrong because he didn't notice the SEMICOLON on the outer loop.

It's not actually nested at all.
First one does nothing but decrement j to 0.
The second one assigns k as j + 1, and and will stop immediately because j is still 0.
So then it prints j and k, which are 0 and 1 respectively.

another question from the exam


am I just being a bitch or is my profesor a dick for having such retarded exam questions?

email him and complain about the retarded questions

That's a very sneaky ;

it is the first exam of the first year?
Or are you in high school?

They're good for training catching retarded bugs.

You're being a bitch with the question 9 for sure, question 10 is more difficult but it's still not rocket science. Get used to academics fucking up code, just treat it as pseudocode and it's fairly obvious what they're attempting to ask you.

Yeah, that's tricky.

these questions are fucking bullshit,
what's next him alternating l and I (L & i) in variable names? | l I

001012
newline won't come in until both nested loops terminate because in C, loops and conditionals only guard the first statement unless you use brackets.

sophomore bro

my engineeiring class is just way more difficult than it should be I think, I literally have gotten 100% on my first two calc 3 exams but am fucking up my engineering class and struggling to keep a B

Implying i & j aren't the prototypical names for counters. It's exactly the same naming convention as K&R.

you're being a bitch

who the hell makes an exam full of trick questions though

I get they are trying to weed people out but thats just a dick move

i regularly use i, j, k, l as counters in 4x nested loops.

There's legitimate reasons for running an empty loop with no statements, maybe the side effects you want can be accomplished within the the loop syntax.
like for example while (*dest++ = *src++);

That's sneaky af. I'd say its unfair, they even indented it to look like it was nested. Still your prof will probably say this teaches you about the debugging process or some shit (even though you weren't able to run it/ actually debug it).

Honestly it's a bad question but there's fuck all you can do about it.

where is the trick in that?

Are you also arguing that mental arithmetic is useless because there are calculators?

>i, j, k, l
i, o, u, p here.

The trick is indenting the printf("\n") statement as if it were part of the outer loop.

>retarded exam questions?
If more people could see these problems immediately, the ImperialViolet exploit wouldn't have happened.

>ImperialViolet
Sorry, just assumed the name of the blog was the name of the exploit.

>just treat it as pseudocode and it's fairly obvious what they're attempting to ask you.
If you treat those two questions like pseudo code you get the wrong answers.

Kek I make nested loops all the time.

this

It's not nested. You would have failed too

that's not his argument, but that's not such a bad argument

>hiding a semicolon in the most pointless place and then using nonstandard formatting to game the less astute into thinking that the second for loop is an inner loop

>again using nonstandard formatting to game the student into assuming the second printf(); is part of the outer for loop

'programming tests' are fucking dumb.

When you work in the field you'll quickly find that everyone lets the compiler/IDE deal with that nonsense and just fucking writes the code

I don't give a shit since programming is a hobby.

that is unfair
the compiler will even throw a warning if you compile it

Shitty intentionally misleading question

Jesus fucking Christ is this an exam question or a snippet from an underhanded C contest entry? If I ever found anything resembling this shit in a codebase I maintained, I'd git blame and post the code on every social platform I could with their name on it. This professor is just a total asshole. As a beginner programmer you shouldn't be expected to compile and execute such esoteric code in your head.

Are you saying you would post screenshots of copyrighted source code and violate your NDA just so you can attack your coworker in a passive aggressive way and rake in some 10 minutes of link karma?

well, it's a dumb trick question with that semicolon. but even if you missed that, you should've got 2 3\n1 2 as the answer. so yeah, you're kinda dumb.

>that's not his argument
It's a very similar argument, though. Being able to simulate sections of code mentally is a useful skill.
>but that's not such a bad argument
It really is, though.

I never understood these dumb questions when I started school. They were completely counter productive. Instead of learning real material that I could implement on my own, they gave us this shit instead.

What a waste of time.

>Sup Forums hobbyist code-artisan can't spot can't spot a semicolon

It's a tricky question but a mistake like this will not always throw a compiler warning and you'll spin yourself in circles trying to figure out what the issue is.

Sucks you lost points but you'll never make that mistake again. Same thing happened to me on an exam.

If I'm looking at it correctly they tricked you by making it look like a nested for loop when it's not. that's total bullshit lol

no output is obviously wrong though

lol;
for (j=2; j>0; j--);
//using semicoloned for loops
//this garbage compiles in your shitty language

No, it really isn't.

Results matter. Whether someone does the math in their head or on a calculator - nobody honestly gives a fuck.

This is like all those english teachers in high school ordering you to write a 5 page report when you could easily manage all the information in 3 paragraphs. In real life, do you think people want a 5 page report or a 3 paragraph report?

Time matters. Results matter. Methods and processes don't matter unless they influence the results.

yes

I've got stupid random trivia questions in a class on linux and windows servers.

It's so fucking pointless. Shit like "What does GNU stand for", "is the command to print lpd or lpr?", and "how do you exit vim?"

This actually insults me. I paid $500 for a class and we're learning nothing and being tested on nothing. Ostensibly the class is on networking and server management, but we're past midterms now and haven't done a single lab, let alone studied how to set up any kind of server.

Our biggest assignment so far has been "make a linux live-usb, bring it to class, plug it into a computer, and show me that it works". I literally had a live usb on my keychain before we'd even gotten the assignment.

Yes, but anonymously. Always write code as if the future maintainer is an utter sociopath and knows where you live. Don't want to get blackballed? Don't write shitty code.

>paying 500 for a single class
I hope this is not a college/uni otherwise I suggest moving to a better school.

These questions are alright on occasion but if it's your entire ciriculum it's literally a waste of time, and you should drop it immediately and find a different school. You can find better.

Stop pretending you've worked in the industry, nobody gives a shit about code quality unless you're entire dev team is less than 10 people and your only income stream comes from something called an "accelerator"

At first I was gonna call you brainlet, but this is super complicated for no reason and just meant to confuse. THis is completely unrealistic too why even ask such a stupid question?

>Results matter.
Exactly. Which is why it matters to be able to be able to reach a simple, approximate result without even having to go through the motions of reaching for your calculator or unlocking your phone as soon as you see the numbers.

It's similar to why being able to type fast as a programmer matters, even though a rather minuscule amount of time is spent actually inputting code -- being able to do smaller changes with less exertion maximizes the amount of small changes that you'll actually make instead of leaving be because it wasn't worth it.

how do you do well on everything but loops and conditionals? what else was the midterm on if you could bomb those topics but they only represented like 25% of the midterm? was the rest of it like "list 5 things your name rhymes with"?

I see friends and family who aren't good at mental arithmetic constantly get confounded by simple numbers like a "375% increase" or a "13:1 exchange rate" because the numbers don't mean anything intuitively to them and they'd have to reach for a calculator to get some real meaning out of it. It seems very debilitating in everyday life.

Not everyone works at a code mill, pajeet. The "industry" is full of rewarding jobs which focus on quality over quantity if you care to look for them. Anything in billing, medical, defense or public utility fit the model. Unfortunately for you, those jobs sound boring because you can't shoot from the hip the whole time, and you're subject to actual quality standards and peer review. Fortunately for me the pay is stellar and I get to do actual software engineering.

Your professor is most definitely a dick for questions like this. If these questions do not specifically start with something like "this is misleading code written by an adversary trying to fool you, tell me what it *actually* does", it's a dishonest question.

yeah because that's how real life is. you show up to review someone's code and you get a nice little warning up front that the code is garbage or deliberately misleading or good. that's not your job to figure out; some magical fairies do that work for you.

you dumb needy bitches

well it tricked me on first glance, but you should have known (no output) couldn't possibly be right

No, you show up get an unexpected output, run gdb and check what's happening and figure it out

>engineering midterm
>online
What country even allows this sort of bullshit?

>It really is, though.
for very simple arithmetic, sure I guess. but anything beyond that and the argument starts to make sense. No one wants some autist fucking up an order because he forgot to carry the 1 or fucked up long division. If you get to real math like statistics or calculus, then I definitely want a computer to do it. Most practical uses of calculus will require numerical methods anyway that I sure as shit wouldn't trust someone to do with pen and paper. You may only have a point if you're talking about higher level mathematics for shit we don't even have practical uses for.

>literally describing what seeing a bug and/or a bug report is

Yes. That IS how real life is. But I guess you're just one of those lucky guys who works on bug-free software then, I'm so jealous.

helps logical thinking

it teaches you how to trace code which helps in debugging

How retarded is everyone here who apparently debugs shitty code by going through it in their head instead of running it with a debugger on?

user didn't even know if statements didn't need curly braces, do you really think that is what the professor was trying to teach? Or that students should be taught new things in an exam at all?

as a swe that reads code daily that was written by non-swe's - ive seen code much worse than this. I've seen someone call out to bash to get the current working directory

>semicolon after the first loop head
>next loop is indented as if it's part of the body of the first loop even though it isn't
That is one fucked up question

What is even the point of the question? Is it a class about deciphering shitty code or what?

>indenting a loop for no reason other than to fuck with you and make you assume things
your professor might be satan himself

how do you think you get to the 10 or 20 lines of code that are causing the bug? you have to work through a fuckton of code to ultimately figure it out. you have to approach everything with some skepticism.

and when you review anyone's code, you can't necessarily just assume that it's fine until you hear otherwise. the whole point is that you assume the worst until it survives/passes the tests. otherwise why the fuck are you reviewing code? why not just deploy it and then run around like a chicken with your head cut off when everything crashes?

i'm sick of students expecting ample warnings of everything. there are so many problems with the way programming and CS are taught and learning evaluated, but this isn't one of those ways. nobody's going to baby you after college. start being an adult.

I think OP is in first year, user.

>didn't even notice the semicolon on the first loop the first time around and thought it was a nested loop
That shit is amazingly easy to hide when it's not even presented in a monospaced font. I'm all for making beginners run code in their head, and for occasionally tricky questions, but there's fucking limits.

Also, why the hell is the return statement indented less than the rest of the code? It's like the professor wanted the code to look as ugly as possible.

first year of what, elementary school? he's in college. he's a goddamn adult. people his age went and fought in fucking wars 100 years ago. the OP is supposed to vote for a world leader every few years. he's supposed to be allowed to drive a fucking car.

treating adults like children without any agency or responsibility is exactly why we have people like OP who feels like he's been tricked. the real world isn't going to whisper into your ear a clue that substantively gives away the answer to your problems.

curve the final grades if people start fucking bombing all the time. but at this point take off the training wheels.

>higher level math we dont even have practical uses for.

brainlet confirmed. stick to vidya.

What a cheeky bastard

user, irl you don't solve systems of differential equations manually, you just input the problem.

This question is fucking retarded. It is formatted wrong just to be confusing and then randomly putting a semicolon. I'm okay with the question testing the semicolon behavior, but they should at least format the code properly.

>people his age went and fought in fucking wars 100 years ago
And died, yes.
>he's supposed to be allowed to drive a fucking car
After lessons, yes.
>the real world isn't going to whisper into your ear a clue
Literally no-one has ever said college is supposed to prepare you for "the real world" by ... what, being the same as it? What would be the point? OP is there to learn to code.

applied mathematics is the only worthwhile mathematics. you can't play with calibi manifolds.

>go to college
>pointless tests on the syntax of some language

thats stupid, you go to a shit school.

its not even testing understanding

It's the sort of thing where you'd get an immediate compilation error, isn't it?

user you are 100% picking the wrong hill to die on.

If I ever encountered code like in picrelated I'd fire the guy on the spot.
t.running my own software company

Didn't you learn C?
It's even early on in the book that it states that brackets aren't even required.

Programming classes shouldnt have tests, just a series of projects to be honest.

You need to test your students to see how well they are absorbing the material. Not the 30/50% tests but the ones worth less as a feedback mechanism for the prof to know if they need to revisit something.

The inner loop starts at k= 1+j and will subtract 1 until k==j, hence is not bigger than j anymore. The loop can be reduced to:
for(int j = 2; j > 0; j--)
print("%d %d\n", j, j+1);
[\code]

That means it prints:
2, 3
1, 2

It's easy to understand that you retard. Next time you run into a problem assume it's you fault not someone else's. God damn niggers make me sick

these are not nested loops my boy