Place Your Query
-
C Programming
-
- Control flow-based C Programs
- Enjoy Conditional Programming in C using If...else and switch statement.
- Good, Now write a C program to display "Hello World" on the screen.
- Write a C program to display Your Name, Address and City in different lines.
- C program to find sum of n numbers
- Write a C program For Addition of two numbers using Function.
- Write a Program to Find Simple Interest and Compound Interest.
- Write a Program to Convert Celsius To Fahrenheit and Vice Versa.
- Write a Program to Find Area and Perimeter of Circle, Triangle, Rectangle and Square.
- Write a Program to Swap Two Numbers Using Temporary Variables and Without Using Temporary Variables
- Write a C Program to Design a Simple Menu Driven Calculator
- Simple Expression Based C Programs
-
- 7. Components of C language
- 1. Introduction to C Programming Language
- 10. Operator Precedence and Associativity
- 11. Comments in C Programming
- 14. Fundamental Control Structure Statements in C [Part-1]
- 15. Fundamental Control Structure Statements in C [Part-2]
- 16. Looping Statements [Fundamental Control Structure Statements in C. #Part-3]
- 17. Keyword break, continue, return and exit [Fundamental Control Structure Statements in C. #Part-4]
- 2. Computer Languages
- 3. Interpreters vs Compilers vs Assemblers in programming languages
- 4. C Program Structure
- 5. Compile and Execute C Program
- 6. Errors in C Program
- 8. C Datatypes
- 9. Operators in C
- Control flow-based C Programs
- Demystifying Bit Masking: Unlocking the Power of Bitwise Operators in C-Language with best Examples.
- 18. Fundamentals of C Functions
- Show Remaining Articles (3)Collapse Articles
-
-
Java
-
AI ML
-
FAQs
- A Program to find Tokens in C code?
- What are the Common Coding Mistakes.
- Easy Learning, Python QAs for Beginner’s to Pro Part-1
- Easy Learning, Python QAs for Beginner’s to Pro Part-2
- Easy Learning, Python Strings QAs for Beginner’s to Pro Part-1
- Easy Learning, Python Strings QAs for Beginner’s to Pro Part-2
- Easy Learning, Python String Functions QAs for Beginner to Pro Part-3
-
Python Interview Questions
- Easy Learning, Python QAs for Beginner’s to Pro Part-1
- Easy Learning, Python QAs for Beginner’s to Pro Part-2
- Easy Learning, Python Strings QAs for Beginner’s to Pro Part-1
- Easy Learning, Python Strings QAs for Beginner’s to Pro Part-2
- Easy Learning, Python String Functions QAs for Beginner to Pro Part-3
11. Comments in C Programming
Comments in the C language is used to provide information about lines of code. They are widely used for documenting code. There are two types of comments in the C language.
- Single Line Comments
- Multi-Line Comments
Single Line Comments
Single line comments are represented by double slash //. Let’s see an example of a single line comment in C.
Syntax:
// use two forward slashes to create a single comment
Example:
// This is a single line comment in code, compiler will not compile this line
#include
int main()
{
// you can place single line comment anywhere in code, as per your need. Like-
//printing information
printf("Welcome to EzyLearning"); // Even you can place comment just after the end of ;
return 0;
}
Output:
Welcome to EzyLearning
Multi-Line comments
A comment that begins with /* and ends with */ can be placed anywhere in your code, on the same line or multiple lines. This feature is useful for adding explanatory notes or temporarily disabling certain parts of the code for testing purposes. Just be mindful not to overuse comments, as they can clutter the code and make it harder to read.
Syntax
/* Sample Multiline Comment
statement-Line 1
statement-Line 2
statement-Line 3
statement-Line 4
statement-Line 5
….
…
*/
Example
#include
int main()
{
/* in main function
one can write any dscription about the problem, code or a statement.
This comment can be of single or multiple lines.
programmer can also this paird character set /*.....*/ to hide a certain set of multi-line-statements
or block of code
*/
int i = 7; //x is a integer variable
printf("%d", i);
return 0;
}
Output
7
Multi-line comments are mostly useful while you are debugging a large set of code, or you want to describe certain set of statements.