Saturday, June 29, 2013

First C Program

Now, we are moving to our first program on C. This program just illustrates you to display the message Hello world,  but along with the program, we are going to understand the structure and the way we are supposed to write the program.

Example 1:


#include<stdio.h> 
main() 
{ 
printf("Hello World \n"); 
return 0; 
}


Follow the steps mentioned below while you develop the above program

  1. Make active the directory where your C programs are in and open the editor and type the above code in it and save it as HELLO.C
  2. Verify whether it is saved in the directory or not.
  3. Compile the program based on the instructions provided by your compiler. You will be getting a message that no errors exists.
  4. If you received any error message, then you may have misspell something in the program. Check for it and correct it, and save it again and compile then.
  5. Then run the executable you have got.
If you have done all the things well, then you can see three files in your directory.
  • Source File
  • Object File
  • Executable File - Generally shown while running.
Once you run the program, you can observe the message Hello World on the screen.

This is how we write a C program.