Search This Blog

Tuesday, July 5, 2022

C Program Comments| C Comments

 C Program Comments| C Programming Comments

C Comments can be single lined or multi lined.

Comments make the program more readable and explains the program in a better way.

Single lined comments start with two slashes (//) , and the compiler ignores those lines i.e. will not be executed by the compiler.

Example of single lined comment:

#include <stdio.h>

int main()

{

//This is a comment.

printf("Hello World!");

return 0;

}

OUTPUT of above program:

Hello World!



Multi lined comment starts with /* and ends with */

so as soon as the compiler comes across /* it starts ignoring those lines from compiling and as soon it comes across */ compiler understands end of comment.


Example of multi lined comments:

int main()

{

/*This is a comment.*/

printf("Hello World!");

return 0;

}

OUTPUT:

Hello World!

C Program for Escape sequence \" | Programming with C language

Programming with C language| C Program with escape sequence \" 

\":: Inserts double quote character.

#include <stdio.h>

int main() {

  printf("My name is \"Johnny\".");

  return 0;

}


OUTPUT of the above Program:

My name is "Johnny".