C Programming Tutorial -2 - Comments









Hey Guys,

In this tutorial I am going to show you how to add comment. In my previous lecture I showed you how to print stuff on screen. In this lecture, I am going to show you how to add comments. It's just little notes to explain what function does or what program does.

There are two ways you can add comments. One of them is to write */ text*/ . For example See this code.

#include <stdio.h>
/* This is my program it prints out my name. it's asome */
int main()
{
    printf("Hello World");

    return 0;
}

Here the output of this code is 

Hello World

So you can see that the comment wasn't included in the print. These comments are mostly used to describe the code.

There is another way you can add comment in which you just have to write // then add comment. For example, see this code.  

#include <stdio.h>

int main()
{//This is my program it prints out my name. it's asome 
    printf("Hello World");

    return 0;
}

This also gives the same output as before which is 

Hello World

I hope this helps. Thanks for reading :) 

Comments