Sunday, July 29, 2012

c programming : Hello World


This is an example of a c console application written and compiled using visual studio 2010:

HelloWorld.c


this program begins with a call to include the header file resource "stdio.h" in order to enable the compiler to comprehend the syntax used.
the next line of code in this program indicates the begining of the "main" function. every c program needs to have a main function that is automatically the first function called:
line "2" also indicates that this function will return an integer value. the open and closed parentheses with nothing between them indicates that this function does not require values called "arguments" to be initialized. The curly brace on line "3" indicates the beginning of the function body.
the following code prints user defined text to the system console, and then waits for the user to enter a key before exiting:

because this function returns an integer value, line "6" is necessary to satisfy that requirement by returning an integer value of "0".

No comments:

Post a Comment