Example 1 — Documenting a calculation
A comment explains the reason for a formula; commented-out code does nothing.
#include <stdio.h>
int main(void) {
double celsius = 25.0;
/* Convert using F = C * 9/5 + 32 */
double f = celsius * 9.0 / 5.0 + 32.0;
// printf("debug: %f\n", celsius); <- ignored
printf("%.1f C = %.1f F\n", celsius, f);
return 0;
} How It Works
- The block comment documents the formula.
- The commented
printfline is skipped entirely. - Only the final
printfproduces output.
