PDA

View Full Version : I just got back from an exam...



whiteflags
11-20-2008, 04:51 PM
I did ok, but it was a weird exam. The two questions where I have the most difficulty in understanding my scoring are:

The statement:
cin >> someInt;
can be interchanged with
someInt >> cin;
[] True
[x] False

(paraphrasing) Writing code in a clean and consistent style is important to
a) the compiler
b) the person writing the program
c) other people reading the source
d) b and c

I missed points on both and I was positive I wouldn't. I suppose you could argue my answer for both. But the instructor hasn't covered bitwise operations (and won't for the rest of class). And well, I just thought d was a reasonable answer for the other.

... Stupid world.

matsp
11-20-2008, 04:58 PM
The first one is indeed FALSE, there is no other valid option. Shifting onto cin will give you a compiler error if cin is the console input stream, and if its an integer, it's as commutative as 2/5 is the same as 5/2 - that is, not at all.

The second question is slightly less clear-cut, but I would have said that c is the predominant (assuming we are discussing this from the goal of being a PROFESSIONAL programmer rather than someone sitting in the attic writing code for him/herself), but b is also important, as we are all human and recognising the code later is much easier if it was written in a consistant and clear manner.

--
Mats

sean
11-20-2008, 05:18 PM
I would also agree with both your answers. What I would do is try the cin thing, and take the specific error to your teacher.

For the other one - you can't PROVE it, but any answer other than D is ridiculous. The compiler ignores whitespace, so A can't be it. The only reason D wouldn't be the correct answer is if you're trying to obfuscate it, and that's me TRYING to be ridiculous.

zacs7
11-20-2008, 05:50 PM
That's terrible!

My SE exam had a similar wtf, "With the concept of Agile programming, what do the following acronyms stand for?". "AIGOAKSAJDKJAD" and like "ASJKDAJSKLDJASKLJD" (not what they were) ... they were seriously that long and I've never heard of them in my life. Granted it's not the same thing, but anyway :p

Is arguing really worth your 2 marks? Probably not. Although if you approach it in a smart way you could get them removed from the exam (ie everyone gets a mark).

Perhaps question 1 means, "will it compile in place of cin >> someInt"?

sean
11-20-2008, 05:54 PM
What I would do is go to the professor and say, "I don't understand how this works - because I tried it and I got an error. How do you get it to work and why would you do that?"

cpjust
11-20-2008, 06:38 PM
Those should be the right answers.
What were the alleged "right" answers, and why?

whiteflags
11-20-2008, 06:47 PM
Our tests are graded by a cold, unfeeling machine so my only recourse is through the professor and hope that she can do something. If you're interested in reading the email I sent to her, this is the body:



[Professor], I can prove that I was marked unfairly on at least three questions after the midterm and possibly a fourth.

11.
The input statement
cin >> someInt;
could also be written as
someInt << cin;
A) True
B) False

As you can see from my answer key I chose false. A simple test program proves that this isn't compilable if cin is a stream.


#include <iostream>
using namespace std;
int main ()
{
int someInt;

cin >> someInt;
someInt << cin;

return 0;
}

Compiling...
foo.cpp
c:\documents and settings\jck\my documents\itcs2530\example\example\foo.cpp(8) : error C2784:
'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,unsigned char)' : could not
deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'int'

If cin isn't a stream, then we are discussing bitwise operations, which are not commutive.

27.
Given the two lines of input data
ABC
DEF
what value is read into ch by the following code? (str is of type string, and ch is of type char.)
cin >> str;
cin >> ch;
A) 'B'
B) ' \n'
C) 'C'
D) 'D'
E) none of the above

As you can see from my answer key, I chose D and the following code proves my answer correct.


#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str;
char ch;

cin >> str;
cin >> ch;

cout << "str = " << str << endl;
cout << "ch = " << ch << endl;
return 0;
}

This is another answer that is suspect:


37.
Formatting a program in a consistent, readable style is valuable to
A) the person who writes the program.
B) other people who need to understand and work with the program.
C) the C++ compiler.
D) a and b above
E) a, b, and c above

I chose D and was marked wrong, but the answer doesn't seem quite as clear-cut.


35.
If x is a float variable containing a positive value, which of the following statements outputs the value of x, rounded to the nearest integer?
A) cout << int(x);
B) cout << int(x) + 0.5;
C) cout << int(x + 0.5);
D) cout << float(x + 0.5);
E) cout << x + int(0.5);

I chose C, the correct answer is marked as A, but my answer is correct in practice.


#include <iostream>
using namespace std;
int main ()
{
float x = 0.6667F;
cout << "int( x ) = " << int( x ) << endl; // prints as 0
cout << "int( x + 0.5 ) = " << int( x + 0.5 ) << endl; // prints as 1
return 0;
}


As these points make a substantial difference in my midterm score, I would like points back where you agree with my demonstrations. Thank you so much for your cooperation and understanding!



We'll see how far that gets me. I'm making my professor sound worse than she is... *shrug*

I didn't really think this thread through btw I just felt like raging.

sean
11-20-2008, 07:09 PM
Those are very well argued responses I think - they don't sound rude at all.

zacs7
11-20-2008, 07:21 PM
It sounds like the computer marking machine messed up... or whoever did the answers doesn't know what's going on.

laserlight
11-20-2008, 11:42 PM
My SE exam had a similar wtf, "With the concept of Agile programming, what do the following acronyms stand for?". "AIGOAKSAJDKJAD" and like "ASJKDAJSKLDJASKLJD" (not what they were) ... they were seriously that long and I've never heard of them in my life. Granted it's not the same thing, but anyway
That would have been fun for a bonus question though :)

hauzer
11-21-2008, 06:23 AM
My SE exam had a similar wtf, "With the concept of Agile programming, what do the following acronyms stand for?". "AIGOAKSAJDKJAD" and like "ASJKDAJSKLDJASKLJD" (not what they were) ... they were seriously that long and I've never heard of them in my life. Granted it's not the same thing, but anyway
So did you found out what those mean?

zacs7
11-21-2008, 06:26 AM
> So did you found out what those mean?
Nope. And I don't see any point in knowing :p

Mario F.
11-21-2008, 07:22 AM
We'll see how far that gets me. I'm making my professor sound worse than she is... *shrug*

I'm not sure how, citizen.
Your professor clearly needs a refresh course in C++ programming, which is a pervasive problem around the globe judging from so many other examples we see on these boards and other places.

On another account, why do you feel 37 is not clear-cut? I cannot see any other option that D. The compiler doesn't care about your coding style in the least.

matsp
11-21-2008, 07:50 AM
I'm not sure how, citizen.
Your professor clearly needs a refresh course in C++ programming, which is a pervasive problem around the globe judging from so many other examples we see on these boards and other places.

On another account, why do you feel 37 is not clear-cut? I cannot see any other option that D. The compiler doesn't care about your coding style in the least.

I agree that C is not the correct answer, but I presume the considered correct answer could be A or B rather than A + B (= D). Although I think D is the right answer.

--
Mats

laserlight
11-21-2008, 07:51 AM
Your professor clearly needs a refresh course in C++ programming, which is a pervasive problem around the globe judging from so many other examples we see on these boards and other places.
I would reserve judgment until the reply. It could well be just a bunch of data entry mistakes.


On another account, why do you feel 37 is not clear-cut? I cannot see any other option that D. The compiler doesn't care about your coding style in the least.
It arguably could just be B since some people can actually read the garbage they spew out :o

Dino
11-21-2008, 07:59 AM
A C++ programming exam is probably no place for a subjective question.

Mario F.
11-21-2008, 08:21 AM
I don't know. Don't find it that subjective. But one can also argue you find subjectivity in many aspects of C++ programming. So...

In any case, these type of questions do make sense to me. Particularly on a basic level such as the one this exam clearly aims at. And the answer is usually an easy exercise of simply excluding the wrong possibilities and finding the encompassing one in case more than one option is right:


D = A AND B.
Since A and B are right answers, D is the only possible answer.
Ignoring either A or B is an error.

EDIT: Remember, the question makes no assumptions as to either A or B. So we must assume both are valid.


I'm sure some of you will help me with the logic rule name that validates my claim. But regarding the professor, laserlight might be right. Out of simple curiosity though, keep us posted citizen.

twomers
11-21-2008, 01:08 PM
>> I'm not sure how, citizen.
The problem is that you're a reasonable person, Mario, who doesn't have anything riding on the test.

People who when they think they know a lot about something and are contradicted with proof on their speciality tend to become defensive, and from my experience, curl up into a ball, ignore the problem and hope the complainer dies or leave the matter rest. However, if one as determined and wronged as I were to not let it go one would be informed of a curious phenomenon computer error which cause your score (and only your score) to be in error, your score is remedied and hey presto, your score wasn't changed until the second visit to the grader...

whiteflags
11-21-2008, 01:21 PM
I was going to wait until there was some sort of announcement before I posted, but my professor wrote me back. She agreed that my answers were marked wrong and corrected my score. She said she would double check to see what the cause of the problem is, so unfortunately I don't know the cause yet. She thanked me.

Considering I was likely the first to take the midterm, she may have simply corrected the master answer key so that no one else has the same problems and won't announce it. I'm thinking that this is a simple mistake as the lecture material never taught such silly answers.

Also, with those points back, I now have an A. Worth it indeed.

twomers
11-21-2008, 01:29 PM
Clearly your professors aren't nearly as cynical as some of mine. Lucky man!

Dino
11-21-2008, 05:44 PM
Also, with those points back, I now have an A. Worth it indeed.

Woo-HOO!!!

Akkernight
11-21-2008, 08:15 PM
Congratz with the A ;)
But that first question thing is so simple that even I can do it o.O ... How can someone possible do that wrong?

Mario F.
11-22-2008, 08:59 AM
But that first question thing is so simple that even I can do it o.O ... How can someone possible do that wrong?

There's so many things that can go wrong with that question.
For one, as citizen made a point to signal, cin isn't defined. Naturally we assume std::cin, but it could be a user-defined type or a native type. Even if a user-defined stream or a native type, there's no guarantee the << operator hasn't been overloaded and what it does.

But, even if std::cin, we could add a twist and mention the possibility of a macro validating both forms, or the possible presence of another << overload.

Of course the answer can only be one, giving the question. :)
But when arguing with your professor, you better cover all the basis.

IfYouSaySo
11-26-2008, 03:04 PM
If I was your professor I wouldn't have given you points back on the first one. You assumed that cin was the same as std::cin, but it does not have to be, and if it wasn't there is nothing that says it *can't* compile:



class mycin {
public:
int val;
void operator>>(int v) { val = v; }
} cin;

void operator>>(int v, mycin& c) { c.val = v; }

int main ()
{
cin >> 5;
5 >> cin;

return 0;
}


maybe i'm a ... donkey ... but I can respect the fact that he wrote a good trick question.

whiteflags
11-26-2008, 03:16 PM
>> You assumed that cin was the same as std::cin

It was correct to do so given how the question was actually written on the exam. I made an earlier post quoting the email I sent my professor: those questions were directly copied from the exam.