Comment in C
Topic : Comment in C
Objectives
In this section we have learn about the comment in C Language. and we also learn about different Types of Comments in C.
AGENDA
- Comments
- Types Of Comments
1. Comments
Comments used to indicate something to the person reading the code. Comments are treated like a blank by the compiler and do not change anything in the codes actual meaning. Comment are used to indicate the code logic and help to generate different signature without effect on code. There are two syntaxex for comments in C, the Original /* */ and the slightly newer //. some documentation system use specially formatted comments to help produce the documentation for code.
Example ://Comment in c #include<stdio.h> int main() { //This is Single Line Comment in c printf("hello world \n"); return 0; /* with this sigh multiline comment is start this is multiline comment in c this is multiline comment in c this is multiline comment in c commment is end with this sign */ }
Output of This Program is
root@Codeworld19:~/Desktop/CPrograms# gcc helloworld.c root@Codeworld19:~/Desktop/CPrograms# ./a.out hello world root@Codeworld19:~/Desktop/CPrograms#
Explanation :
in the above Program the comment line are not show in the output. in the output only print statement are execute. the comment line are highlighted with light yellow colour in the program and the output of the program in also highlighted with the light yellow colour.
2. Types Of Comments
There are two types of comment
- Single Line Comments
- Multi-line Comments
This Type of Comment start with two forward slashes and runs to the end of a line.
Example :
//this is a single line comment in C
This type of comment does not allow multi-line comments, through it is possible to make a comment block by adding several single line comment one after the other
Example :
//this is a single line comment in C //this is a single line comment in C //this is a single line comment in C //this is a single line comment in C //this is a single line comment in C
This types of comment may be used on its own line or at the end of a code line. However, because they run to the end of the line, they may not be used within a code line.
1 2 3 4 5 6 7 8 | #include<stdio.h> // this is a header file int main() { //This is Single Line Comment in c printf("hello world \n");//this is a print statement return 0; // the main method is over after return 0; statement } |
2.2 Multi-line Comments
A Comment start with a forward slash followed immediately by an asterisk(*), and eds as soon as an asterisk (*) immediately followed by a forward slash is encountered. Everything in between these character combinations is a comment and is treated as a blank. the comment are basically ignored by the compiler.
Example :
1 2 3 4 5 6 7 8 9 10 11 12 | #include<stdio.h> int main() { printf("hello world \n"); return 0; /* with this sign multiline comment is start this is multiline comment in c this is multiline comment in c this is multiline comment in c and the end the mutiline comment with this sigh */ } |
Are You an Apple Products user then this all stuff relates to you because here we shared the some of the common issues with the solution for You Below
How to Download iOS 14 Update | iOS 14 Overview
How to Reset Apple ID Security Questions
How to create a new Apple ID on iPhone or iPad
iOS: iPhone Update Error: Unable to Install Update
Apple Support Phone Number
How to Install the iOS 13 Beta On iPhone & iPad | iOS 13 update
iOS 12 problems: how to fix issues in iOS 12.1.4 Update| Customer Service