Hello World program in c - thecodesgallery.com


If you are beginner in coding, if you want to creat your first C program, then this page is for you.
Before you write your first program you learn first, basic structure of C programming.
This helps to understand C program very easily.
Ok! lets get started.

Basic Structure of C Programming :

     The different programming languages have there own formate of coding.
     The basic components of C program are as follow.

* Header file
* Main function
* A pair of curly braces
* Block of statement
* User defined functions

Header file -

The header file begins with '#' symbol these statement direct the C processor to include header files and symbolic constants.
      All the header files ends with a keyword '.h' .
Ex : 
#include<stdio.h> or #include "stdio.h>"  -  It stands for standered input output function.

* Input function : 
 scanf(): This function  accept the values from the users.

* Output function :
 printf() : This function  is used to print on the screen what user was  want.

Main function - 

As the name itself indicates,this is the main function of every C program. Without main function C program is not executed. Every C program start with main function. The main function is written in lower case later.

A pair of curly braces -

Every C program uses a pair of curly braces ({}),
the left brace indicates the beginning of the main function and right brace indicates the end of the main function.

Declaration -

The declaration is a part of  C program were all the variables, arrays, functions used in the C program are declared and may be initialised  with basic data type.

Statement -

These are instructions to the computer to perform some specific operations they may be input, output, statement, arithmetic statement, control statement and other statements.

User defined function -

These are sub programs generally a sub program means is a function. The user define a function contain a set of statements to perform a specific task. These  statements are written by users that's why it is called user defined function.

Syntax :

#include<stdio.h>      -- Header file
void main()                 -- Main function
                                   -- Pair of curly braces
     
      declaration;
      statement;

}
user defined functions 

Hello World program in C :


 #include"stdio.h"
void main(){
printf("Hello world!");
}
 

Output :

Hello World program in c - thecodesgallery.com




Post a Comment

You are welcome to share your ideas with me in the comments!

Previous Post Next Post