Online C Programming Quizzes

D

Dexter

My site is home to series of quizzes ranging from Accounting,
Business, Math to programming languages. These are multiple choice
type questions and you get a score card at end.

For C language, I have 3 set of quizzes that anyone is welcome to try
online for free.
Questions on C quizzes are rather easy to solve for Professional C
programmers yet for those who are taking C as a first programming
course will find these useful in assesment their C
knowledge


Visit http://www.thinkanddone.com/exams/main.aspx


Regards


Asad S. Yousaf
 
A

Army1987

My site is home to series of quizzes ranging from Accounting,
Business, Math to programming languages. These are multiple choice
type questions and you get a score card at end.

For C language, I have 3 set of quizzes that anyone is welcome to try
online for free.
Questions on C quizzes are rather easy to solve for Professional C
programmers yet for those who are taking C as a first programming
course will find these useful in assesment their C
knowledge


Visit http://www.thinkanddone.com/exams/main.aspx
I found something wrong already at the first level.
Question 3 is:
3 . Its given that variable x has been assigned a value of 5, which of the following statement will output the message "I am quite right"
if (x!=5) printf("I am quite right");
if (x=5) printf("I am quite right");
both statements will display the message
none of the above
The second statement will assign 5 to x (which happens to already
have that value, but that's irrelevant) and, since the result of
that assignment can never be zero, it will execute the expression
statement consisting of the printf call. So I checked the second
answer, but the test believes the correct answer to be "none of
the above".
 
B

borophyll

My site is home to series of quizzes ranging from Accounting,
Business, Math to programming languages. These are multiple choice
type questions and you get a score card at end.

For C language, I have 3 set of quizzes that anyone is welcome to try
online for free.
Questions on C quizzes are rather easy to solve for Professional C
programmers yet for those who are taking C as a first programming
course will find these useful in assesment their C
knowledge

Visithttp://www.thinkanddone.com/exams/main.aspx

Regards

Asad S. Yousaf

Some of the questions could be better worded, and some of the
questions are just plain wrong.

--------------
Dataset 1
--------------

Question 1 states: A C program is a collection of ______________
(a) arrays
(b) variables
(c) functions
(d) data types

Neither of these answers are correct, though you state that (c) is the
answer. A C program is more than a collection of functions. What
about object declarations? Type declarations? The correct answer
should be "declarations".

Question 3 states: Its given that variable x has been assigned a value
of 5, which of the following statement will output the message "I am
quite right"

(a) if (x!=5) printf("I am quite right");
(b) if (x=5) printf("I am quite right");
(c) both statements will display the message
(d) none of the above

You give answer (d) as the correct answer, when in fact the correct
answer is (b). Remember, assignment expressions have a value too...

Question 6: I don't like the wording of this question. The term
"assignment" here I think is not really correct

---------------
Dataset 2
---------------

Question 1: This may just be a language barrier issue, but
"alphabets" should be "letters"

Question 5: I'm not sure that you should be so dogmatic about the use
of infinite loops. They should not be used if you can avoid them, but
I know Linux uses them a lot. Perhaps there are cases where you need
to use them...

Question 8: This may be bit-picking, but my interpretation of the
Standard is that void actually *is* a value, but it is an empty value
that cannot be used. I would be interested to know why this
description was used. Why not just say void means "returning no value"

Question 9: Sorry, your answer is wrong. You declare an array of 10
characters. You can fit 10 characters in it. The answer is not 9.
There is no rule that the last element of an array of char must be a
null character. And even if there was, the null character is *still*
a character!

--------------
Dataset 3
--------------

Question 2: Replace the word "commands" with "directives"

Question 3: Where is the condition contained in round brackets?

Question 6: Answer (d) is correct, not answer (c)

Question 7: Answer (c) is given as correct, but goto is not a loop
statement

Question 8: A function *always* returns one value. Just because it
is a pointer does not mean that it returns *many* values

Question 9: All arguments are pass by value

Question 10: 12 bytes is incorrect. The value is implementation
defined, because a structure may have any amount of padding between
its members or following the last member.


Regards,
B.
 
P

pete

Question 8: This may be bit-picking, but my interpretation of the
Standard is that void actually *is* a value, but it is an empty value
that cannot be used.

An expression of type void has a nonexistent value,
which to my way of thinking,
means that expressions of type void don't have values.

N869
6.3.2.2 void
[#1] The (nonexistent) value of a void expression (an
expression that has type void) shall not be used in any way,
and implicit or explicit conversions (except to void) shall
not be applied to such an expression.
 
P

pete

Some of the questions could be better worded, and some of the
questions are just plain wrong.

--------------
Dataset 1
--------------

Question 1 states: A C program is a collection of ______________
(a) arrays
(b) variables
(c) functions
(d) data types

Neither of these answers are correct, though you state that (c) is the
answer. A C program is more than a collection of functions. What
about object declarations? Type declarations? The correct answer
should be "declarations".

External declarations.

A C program consists of:
1 preprocessor directives
2 comments
3 external declarations
4 extra white space
 
F

Flash Gordon

pete wrote, On 06/10/07 09:47:
External declarations.

A C program consists of:
1 preprocessor directives
2 comments
3 external declarations
4 extra white space

To get a C program you need at least one definition (although a
definition is of course also a declaration). If your are including
comments in your list, then why not statements?
 
B

borophyll

Question 8: This may be bit-picking, but my interpretation of the
Standard is that void actually *is* a value, but it is an empty value
that cannot be used.

An expression of type void has a nonexistent value,
which to my way of thinking,
means that expressions of type void don't have values.

N869
6.3.2.2 void
[#1] The (nonexistent) value of a void expression (an
expression that has type void) shall not be used in any way,
and implicit or explicit conversions (except to void) shall
not be applied to such an expression.

Agreed, I was too lazy to look it up properly
 
P

pete

Flash said:
pete wrote, On 06/10/07 09:47:

To get a C program you need at least one definition (although a
definition is of course also a declaration). If your are including
comments in your list, then why not statements?

Because statments are part of function definitions
and function definitions are external declarations.
 
P

pete

pete said:
Because statments are part of function definitions
and function definitions are external declarations.

N869

6.9 External definitions

[#4] As discussed in 5.1.1.1, the unit of program text after
preprocessing is a translation unit, which consists of a
sequence of external declarations.
 
B

borophyll

pete said:
Flash Gordon wrote:
Because statments are part of function definitions
and function definitions are external declarations.

N869

6.9 External definitions

[#4] As discussed in 5.1.1.1, the unit of program text after
preprocessing is a translation unit, which consists of a
sequence of external declarations.

The question would need to be qualified as "preprocessed C program"
for it to be precise

Regards,
B.
 
D

Dexter

I found something wrong already at the first level.
Question 3 is:
3 . Its given that variable x has been assigned a value of 5, which of the following statement will output the message "I am quite right"
if (x!=5) printf("I am quite right");
if (x=5) printf("I am quite right");
both statements will display the message
none of the above
The second statement will assign 5 to x (which happens to already
have that value, but that's irrelevant) and, since the result of
that assignment can never be zero, it will execute the expression
statement consisting of the printf call. So I checked the second
answer, but the test believes the correct answer to be "none of
the above".

--
Army1987 (Replace "NOSPAM" with "email")
A hamburger is better than nothing.
Nothing is better than eternal happiness.
Therefore, a hamburger is better than eternal happiness.

I made errors when compiling the examset. Many thanks for your insight
into C topics

I have reloaded DataSet1 with error proned question replaced with new
ones.

DataSet2 and Dataset3 have been unloaded and will be corrected and
reloaded later this afternoon
 
A

Army1987

I made errors when compiling the examset. Many thanks for your insight
into C topics

I have reloaded DataSet1 with error proned question replaced with new
ones.

I think that the point you were trying to verify with that
question, namely the difference between comparison and assignment,
is important, but using zeroes instead of fives you could verify
it without the test expecting a factually incorrect answer.
 
A

Army1987

External declarations.

A C program consists of:
1 preprocessor directives
2 comments
3 external declarations
4 extra white space
You should make up your mind. Is the program the set of
preprocessing-files or of (preprocessed) translation units? In the
former case, they are made by groups of lines, and each line is
either a directive or it isn't. At this level, doing that
distinction is not very useful, as external declarations could be
built with macros and/or other IOCCC preprocessing trickery.
In the latter case, after preprocessing (translation phases 1-4)
there are no more comments, and translation units are made of
external declarations. See A.2.4 and A.3.
 
A

Army1987

Some of the questions could be better worded, and some of the
questions are just plain wrong.
Well, ++E is defined in terms of (E+=1), so the distinction is
really immaterial.
---------------
Dataset 2
---------------
Question 9: Sorry, your answer is wrong. You declare an array of 10
characters. You can fit 10 characters in it. The answer is not 9.
There is no rule that the last element of an array of char must be a
null character. And even if there was, the null character is *still*
a character!
IIRC it talks about strings. Anyway, since the null is part of the
string, but the length of a string is defined as the number of
characters excluding the null, the wording shoul be "of length 9"
not "of 9 characters".
 
P

pete

Army1987 said:
You should make up your mind. Is the program the set of
preprocessing-files or of (preprocessed) translation units?

No.
A program is the source files.
Have you ever written a C program?

N869
5.1.1.1 Program structure
[#1] A C program need not all be translated at the same
time. The text of the program is kept in units called
source files, (or preprocessing files) in this International
Standard.
 
?

=?iso-2022-kr?q?=1B=24=29CHarald_van_D=0E=29=26=0F

No.
A program is the source files.

In other words, the preprocessing files (from the text you quoted).
Preprocessing files consist of lines, not external declarations. The
preprocessed translation unit will consist of external declarations, but
the preprocessed translation unit is not a source file.
Have you ever written a C program?

Was that necessary?
 
P

pete

=?iso-2022-kr?q?=1B=24=29CHarald_van_D=0E=29=26=0Fk?= said:
In other words, the preprocessing files (from the text you quoted).

Yes. I said the wrong thing.
Preprocessing files consist of lines, not external declarations. The
preprocessed translation unit will
consist of external declarations, but
the preprocessed translation unit is not a source file.


Was that necessary?

Thinking about what writing a C program involves,
should give you some idea of what a C program is.
 
¬

¬a\\/b

In data Sat, 06 Oct 2007 13:56:48 -0400, pete scrisse:
Yes. I said the wrong thing.


Thinking about what writing a C program involves,
should give you some idea of what a C program is.

A C program is a written text that follow the definitions of the C
language text definitions
 
S

santosh

¬a\/b said:
In data Sat, 06 Oct 2007 13:56:48 -0400, pete scrisse:

A C program is a written text that follow the definitions of the C
language text definitions

A C source file is written text. A C program is an executable which was
compiled from a C source file.
 
K

Karl Heinze


There's an error here:

3 . Its given that variable x has been assigned a value of 5, which of
the following statement will output the message "I am quite right"

o if (x!=5) printf("I am quite right");
o if (x=5) printf("I am quite right");
o both statements will display the message
o none of the above

You say "none of the above" is the correct answer; but actually "if
(x=5) printf("I am quite right");" is the correct answer.


K. H.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,832
Latest member
GlennSmall

Latest Threads

Top