Skip to Content
Absolute Beginner's Guide to Programming, Third Edition
book

Absolute Beginner's Guide to Programming, Third Edition

by Greg Perry
November 2002
Beginner content levelBeginner
432 pages
11h 44m
English
Que
Content preview from Absolute Beginner's Guide to Programming, Third Edition

C Comments

A C comment is the same as a Visual Basic remark. Comments document the code. A comment begins with /* and ends with a closing */, even if the comment spans several lines of code. C comments can go anywhere in a program, including the end of a line.

What does the following C statement do?

return ((si < s2) ? si : s2));

How could anyone expect to know what that statement does? Even an advanced C programmer will have to analyze the statement for a while to understand it. A simple comment makes everything much easier, as the following statement shows:

return ((s1 < s2) ? s1 : s2); /* Finds the smaller of 2 values */

From the comment, you know that the statement locates the smaller of the two values stored in s1 and s2 (s1 and s2

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Absolute Beginner's Guide to Programming, Second Edition

Absolute Beginner's Guide to Programming, Second Edition

Greg Perry

Publisher Resources

ISBN: 0789729059Purchase book