Online C Programming Quizzes

S

santosh

Karl said:
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.

Yes, but I suspect the question itself is misleading. I think the OP
meant to write an equality comparison in the second if, not an
assignment.

Or it may be that he, (the OP), _did_ mean an assignment to illustrate
that in C an assignment expression evaluates to the value of the LHS
after the assignment.
 
B

borophyll

Well, ++E is defined in terms of (E+=1), so the distinction is
really immaterial.> ---------------

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".
--
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.

We can't be sure, since it appears our friend has removed datasets 2
and 3
 
B

borophyll

Yes, but I suspect the question itself is misleading. I think the OP
meant to write an equality comparison in the second if, not an
assignment.

Or it may be that he, (the OP), _did_ mean an assignment to illustrate
that in C an assignment expression evaluates to the value of the LHS
after the assignment.

We cannot know what the OP meant, but either way (b) is still the
correct answer
 
M

Malcolm McLean

santosh said:
A C source file is written text. A C program is an executable which was
compiled from a C source file.
That's a program written in C.
A C program is a collection of one or more source files including a main()
and all subroutines called from it, excluding those in libraries it is
dependent upon.
 

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,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top