Thread: Some C test questions: challenge

  1. #1
    CS Author and Instructor
    Join Date
    Sep 2002
    Posts
    511

    Lightbulb Some C test questions: challenge

    I am a computer science instructor. One of the classes I teach on a regular basis is C programming. I need some help on creating C test questions. I have many test banks from many different texts in C, C++, Java, C# and VB that I use. However, I am asking you people who post on this board to come up some true/false and multiple choice questions over the following topics:

    functions, files: binary and text, linked lists, bitwise operations, characters and strings, structures, arrays and pointers, loops and selection statements.

    I would like the question as well as the answer posted. I will use the questions on my future C exams.


    Thanks

    Mr. C.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    True or false: The programmers at www.cprogramming.com suggest you use 'void main'?

    Make that be 100% of the grade.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    Oh man, that was funny quzah.

    I guess alot of us will tell you that you need to make sure not only are you teaching the common syntax of c, and the way to write it elegantly and effeciently, but to not teach things that are undefined.

    IE: void main()
    Last edited by Shadow; 09-06-2002 at 08:52 PM.
    The world is waiting. I must leave you now.

  4. #4
    CS Author and Instructor
    Join Date
    Sep 2002
    Posts
    511
    I have told my students to mark 0 for false and 1 for true on T/F questions in the past.

    However, most of the time the students cant read the directions. So they mark T or F.

    I make my student follow a list of coding standards. I don't let them use void main() or void main(void)
    Mr. C.
    Last edited by Mister C; 09-06-2002 at 08:56 PM.

  5. #5
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    Ok, I recommend taking a point off from the score if they didn't follow directions. Furthermore, add questions that use the implimentations you have taught, but have them be altered in such a way, so you may test if what you're teaching is really being absorbed.

    Something that I find to be interesting in my Visaual Basic.NET course, is the fact that we have "go on your own" exercises. We have to do things, in a different fashion, that we already know how to do, on our own - with no help. Try constructing a question that is similar to this method. I really encourage giving them the "stuck in the middle of nowhere" test. After all that's what they will be doing in the field, working on their own.

    Test them, to see if they'll be fired later on.

    That's my suggestion.
    The world is waiting. I must leave you now.

  6. #6
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Ok here's one:

    Code:
    int x = 7;
    
    x ^= x;
    x now contains
    a. 7
    b. 0
    c. 8
    d. 14

    Answer: 0

  7. #7
    KingoftheWorld
    Guest
    I just wonder why don't you have a exam/test guildline manual which is designed for instructors only. This guildline usually come
    with the textbook you use for the class.
    Any way, im my opinion your test would be part of multiple choices, part of T/F and short answer or make small code segments for students to fill in or finding its missing syntax....

    There is a good joking that doing Test or Exam with multiple choice is like playing lottery. Students can guess without knowing
    what the test is talking about???

    KingoftheWorld

  8. #8
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Code:
    long X = 23;
    X = X << 3;
    X now contains:
    a) 32
    b) 184 << answer
    c) 92
    d) 138

    Code:
    int a = 5;
    int b = 26;
    
    a ^= b;
    b ^= a;
    a ^= b;
    A and B are now:
    a) 31, 5
    b) 5, 0
    c) 5, 26
    d) 26, 5 <<
    Last edited by XSquared; 09-06-2002 at 10:12 PM.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  9. #9
    KingoftheWorld
    Guest
    A sample test question:

    Code:
      int a;
      int  b  = 4;
      int  c  = 7;
    
      a = ++b+++c;
    
      printf("a value is:  %d", a);
    what the output value of a will be?


    KingoftheWorld

  10. #10
    CS Author and Instructor
    Join Date
    Sep 2002
    Posts
    511
    Shadow:

    I do have them write short code segments and write programs inclass for the exams. And I usually have debugging problems as well. I will try the "go on your own" approach. As I have an idea for both.

    King of the world

    You are right most textbooks have exams and study guides and course outlines for the exams. I use them whenever I can. But I wanted the programmers/lurkers/students here at C Programming.com to just give me some of there test question ideas. You are right about multiple choice they can guess the right answer- without really knowing the material. But I like to have a variety of question types on my exams.

    Thats why I am asking for all your input for just these question in particular for now.

    Here is an example:

    What is displayed after the following?

    int radius = 21;
    int z = 12;

    radius = (++radius) + (z++);
    radius = (radius++) + (z++);
    printf (“Radius = %d”, radius);

    A. Radius = 45 C. Radius = 47
    B. Radius = 46 D. Radius = 48

    Sorry, if I did not use the proper formatting tags. I am still new here!! I will get it write the next time.

    Mr. C.

  11. #11
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > radius = (radius++) + (z++);
    Yet again, someone thinks a question with lots of ++ operators in it makes a good question.
    It isn't - it's wrong

    Is this one big test at the end, or a series of tests based around the chapters in some book?

    Here's a question
    Compare and contrast the use of bitwise & and logical &&
    http://www.cprogramming.com/cboard/s...threadid=24197
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  12. #12
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    Originally posted by Mister C

    What is displayed after the following?

    int radius = 21;
    int z = 12;

    radius = (++radius) + (z++);
    radius = (radius++) + (z++);
    printf (“Radius = %d”, radius);

    A. Radius = 45 C. Radius = 47
    B. Radius = 46 D. Radius = 48
    undefined smart boy.
    hello, internet!

  13. #13
    Blank
    Join Date
    Aug 2001
    Posts
    1,034
    What is the answer to this

    Code:
    int a = 4, b = 3;
    if (a == 4)
         if (b != 3)
                printf("a = 4 and b = 3\n");
    else
         printf("a != 4\n");
    The solution is
    Code:
    int a = 4, b = 3;
    if (a == 4)
         if (b != 3)
                printf("a = 4 and b = 3\n");
         else
                printf("a != 4\n");
    The nearest unmatched if statement is matched with the
    else.

    I wouldn't try to trick the students that much though. Maybe
    have a question with about 3 variables and 3 pointers and manipulate them then ask what is the value of
    a, b, c, *aptr, *bptr, *cptr etc. Perhaps write some code
    for a linked list and then let the students write code to merge
    two of the linked list together into an array or a linked list.
    The problem with true false is that the student has a 50%
    chance of getting it write. Usually in these type of questions
    there's a way to guess the answer.

  14. #14
    CS Author and Instructor
    Join Date
    Sep 2002
    Posts
    511

    Talking

    Thanks for all your help in giving real good test questions. Also, thanks for all of the suggestions to make my testing and course better. I forgot to post the answer to my test question. the answer is D. radius = 48.

    Continue to post questions as I will check back when I have time.

    Mr. C.

  15. #15
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > I forgot to post the answer to my test question. the answer is D. radius = 48
    I tried to warn them, but they didn't listen

    History is repeating itself, just as it has always done
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie needs help..
    By xpress urself in forum C++ Programming
    Replies: 3
    Last Post: 07-26-2007, 07:22 PM
  2. A very long list of questions... maybe to long...
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-16-2007, 05:36 AM
  3. My C++ test is COMING!!...
    By [Z-D] in forum C++ Programming
    Replies: 52
    Last Post: 12-01-2006, 08:02 PM
  4. undefined reference
    By 3saul in forum Linux Programming
    Replies: 12
    Last Post: 08-23-2006, 05:28 PM
  5. Bitwise Test Questions
    By Mister C in forum C Programming
    Replies: 9
    Last Post: 11-27-2002, 06:06 PM