quick.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

   

space.gif

   

space.gif

  ../images/main/bullet_green_ball.gif Hello World

As usual, like in in other sections of my website, I start with Hello world. Open your favorite editor, and type below code and save it

   

space.gif


 1 #include <stdio.h>
 2 
 3 void main() 
 4 {
 5   printf("\nHello World\n\n");
 6 }
 7 
You could download file hello_world.c here
   

space.gif

compile it by typing:

   

space.gif

gcc hello.c

   

space.gif

This creates an executable file a.out, which is then executed simply by typing its name. The result is that the characters ' Hello World' are printed out, preceded by an empty line.

   

space.gif

A C program contains functions and variables. The functions specify the tasks to be performed by the program. The 'main' function establishes the overall logic of the code. It is normally kept short and calls different functions to perform the necessary sub-tasks. All C codes must have a 'main' function.

   

space.gif

Our hello.c code calls printf, an output function from the I/O (input/output) library (defined in the file stdio.h). The original C language did not have any built-in I/O statements whatsoever. Nor did it have much arithmetic functionality. The original language was really not intended for 'scientific' or 'technical' computation.. These functions are now performed by standard libraries, which are now part of ANSI C. The K & R textbook lists the content of these and other standard libraries in an appendix.

   

space.gif

The printf line prints the message 'Hello World' on 'stdout' (the output stream corresponding to the X-terminal window in which you run the code); '\n' prints a 'new line' character, which brings the cursor onto the next line. By construction, printf never inserts this character on its own.

   

space.gif

   

space.gif

   

space.gif

   

space.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

  

Copyright © 1998-2014

Deepak Kumar Tala - All rights reserved

Do you have any Comment? mail me at:deepak@asic-world.com