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:
- Click on Run Menu->
- Then click on compile option ->
Shortcut of Compile is : Alt + F9 Key
For run a program:
- Click on Run Menu
- Click on Run Option
Shortcut of Run program is : Ctrl + F9 Key
If you want to make an executable file (.exe) :
- At first, you have to compile the program (Alt+F9)
- Click on Compile menu
- Then click on make option
Shortcut for Make a program: F9 Key
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
Subroto Mondal
Latest posts by Subroto Mondal (see all)
- Installing and Configuring OpenShift: A Step-by-Step Guide for Linux Experts with Terminal Code - February 19, 2023
- Sed Command in Linux with Practical Examples - February 19, 2023
- Rsync Command uses with examples - February 19, 2023