Mphatso
asked

Expert
Kelish Rai answered
Yes, you can write as many single-line comments as you want in your program.
Comments are simply there to help us understand the code better—they're not read or executed by the computer. So whether you're explaining a complex line or just noting something down for later, using many single-line comments is completely fine.
Here’s a quick example:
// This program prints a number
#include
int main() {
int number = 5; // Declare a variable
printf("%d", number); // Print the value of number
return 0;
}
Each //
comment is considered a single-line comment, and you can write one before or after a line of code, or even leave full lines just for comments.
You can also use multi-line comments if you want to write longer explanations that span across several lines. In C, multi-line comments are written like this:
/* This is a multi-line comment.
You can write across multiple lines,
and it ends with a closing */
C
This question was asked as part of the Learn C Programming course.