Monday, January 09, 2012

Write Your First Program in C


  /* HelloWorld.c : This is my first C program */
  #include <stdio.h>

  int main()
  {
     printf ("Howdy, neighbor! This is my first C program.\n");
     return 0;
  }

A C program must save in a file with .c extension.

Now in my C code first line contains a comment:
  /* HelloWorld.c : This is my first C program */
Which start with /* and end with */

In second line: #include <stdio.h> tells the C preprocessor to look for a file and place the contents of the file in the location where the #include directive indicates.

Main part of the C program is the main function because without a main fuction C program can not able to execute.

printf() a C library function is called to print message.

Every C function have a return type. usually main function return 0 or void.


 

No comments:

Post a Comment