by David Hamrick

Home
Links

Starting Out
Compiler
Hello World Program
Comments

Variables
Int, Char, Float

Scanf

Projects
ATM project
Maze project
Unit Conversion project


Comments

Comments are a vital part of C Programming. It allows you to remind yourself of what parts of your program do. It allows you to take part of the program out without deleting them.

There are two different types of comments that will be shown here. Firstly the old style multi line comment.

The old style comments allow you to do multiple lines of comments. For example

#include <stdio.h>

int main()
{
  /*
  printf("This won't be executed because its inside a comment");
  printf("This won't be executed either");
  */
  printf("This will be executed");
  return 0;
}

If you run that program you will only see -
This will be executed
This is because we commented out the other lines. This means that that data is overlooked by the compiler and it doesn't read data untill it gets to the other end of the comment. /* Hello */

The new Style comments are based on Lines of code. For example

printf("This line is not commented");
//printf("This is line is commented");

All that will appear on the screen is -
This line is not commented

Comments are a very simple, easy but very vital part of programming.
 


 

 

Hosted by www.Geocities.ws

1