Comments#
Introduction#
Comments in C++ are used to add explanations or notes within the code. They do not affect how the code runs and are useful for clarifying logic, documenting functionality, or temporarily disabling parts of the code.
Comments#
A single-line comment starts with // and continues until the end of the line.
// This is a single-line comment
printf("Hello!") // Print a greeting message
// Print a greeting and then a farewell
printf("Hello!")
printf("Goodbye!")
Multiline String Comments#
C++ uses block comments (/* … */) for multi-line explanations. These are true comments and are ignored by the compiler.
/*
This project prints a greeting message,
followed by a farewell message
*/
printf("Hello!")
printf("Goodbye!")