Sample C Hello World Program

Sample C hello world program: A program that displays “Hello World” String on screen.This program I used, printf library function is used to display text on the screen, ‘\n’ places the cursor at the beginning of next line, stdio.h header file contains a declaration of printf function. The code will work on all operating systems may be its Linux, Mac or any other and compilers.

 
//C hello world example 
#include <stdio.>      //Header Section 
int main()               //Main Function, Actually only that section C / C++ compiler execute 
{                        //Body Starts here 
   printf("Hello world\n"); //printf function prints massage or variable value to out side world 
   return 0;            // This is return value of main function 
}                       //End of body or main function 

 

Another program that’s print a variable value

 

 
//C hello world example 
#include <stdio.h>           //Header Section 
int main()                   //Main Function, Actually only that section C / C++ compiler execute 
{                            //Body Starts here 
   int a=100;                //Declaration of variable named a that holds value 100
   printf("The value of a is %d\n",a);  //printf function prints massage or vaiable value to out side world 
   return 0;                 // This is return value of main function 
}                            //End of body or main function 

Steps for compile and run a program:

For Compile:

  1. Click on Run Menu->
  2. Then click on compile option ->

Shortcut of Compile is : Alt + F9 Key

Compile

For run a program:

  1. Click on Run Menu
  2. Click on Run Option

Shortcut of Run program is : Ctrl + F9 Key

Run

If you want to make an executable file (.exe) :

  1. At first, you have to compile the program (Alt+F9)
  2. Click on Compile menu
  3. Then click on make option

Shortcut for Make a program: F9 Key

make

Making a program convert source code to an executable binary file, and it will be ready to execute on any computer. After making the program you can find the Exe file at desired location you have preset at “output location”.

To Set, you desire location of the makefile.

  • Click on Option Menu ->
  • Click on Directory Option->
  • At output location set your output file path

make location

 

 

The following two tabs change content below.

Subroto Mondal

Chief Coordinator HR&CR
I like Programming and New Technologies. And work with Linux.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.