< C Tutorial

C first program

← Previous Next →


Consider the below famous "Hello World" program code:

#include <stdio.h>

int main()
{

   /* This is a first hello world Program */
   printf("Hello World\n");
   
   return 0;
}

Different parts of C program.

  • Pre-processor
  • Header file
  • Function
  • Variables
  • expression
  • Comment

Pre-Processor

The preprocessor provides the ability for the inclusion of header files, macro expansions, conditional compilation, and line control. #include  is the pre- processor used in this program.  It is used to include code written in the header file <stdio.h>

Header File

Header file contains built-in or ready made functions, definitions which you can directly use in the program.  
stdio.h is a header file used in this program. It contains function like printf to printing data in the screen.

Function:

C programs are divided  into units called functions. The above code has only one function defintion main(), the operating system always passes the control to the main() function when a c program is executed. It means program starts from main function.

 


 

Compile and Run:

There are many different ways to compile and run a C program. All that is required is a C compiler. You can folow instruction to download one of it from c_compiler_installation

Step 1 :

Open turbo C IDE(Integrated Development Environment), click on File and then click on New


Step 2 :

Write the above example as it is

 Step 3 :

Click on compile or press Alt+f9 to compile the code

Step 4 :

Click on Run or press Ctrl+f9 to run the code

Step 5 :

Output

 

 

← Previous Next →