Wednesday 4 May 2016

Stupid C Programming Part 3 (The First C Program)

This is the time to write the first program in C Language.

#include<stdio.h>
void main()
                  {
                      printf("This is my first C Program");
                   }
So here we have a program and the program and the program will print the line " This is my first C Program " on the screen.

Now, lets understand the program line by line:
The first line #include<stdio.h> includes a file called Header file. The header files a libraries, where some methods are written to use in the program. Here we use a method printf(), which prints the line in the console and this method is defined in the header file "stdio.h". We can create our own header file and store it to use.

The next line is void main(){}, it defines the "main" method of the program. Every program must contain one main method at least. This is the entry point of a program. the program execution get started from main method. So at the beginning the execution environment finds out the main method and then it executes the instructions written in the program.

The next is printf("This is my first C Program"); this is a pre defined method in stdio.h header file. This method prints something according to the given input. There are several predefined methods in C libraries and we will use some of them time to time.

No comments:

Post a Comment