BACK TO 10+2 STEM LAB
10+2 MATHEMATICS & DRAWINGS•2016-05-11•3 MIN READ

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, ' ' places the cursor at ...

Key Architecture Takeaways

  • ›
    Point 1: Core computer science and engineering computing concept: Sample C Hello World Program.
  • ›
    Point 2: Detailed trace of memory representation, algorithmic complexity, and control structures.
  • ›
    Point 3: Includes portable ISO C (C17/C23) code examples verified with modern GCC and Clang.
Notice

Compiler & Toolchain Modernization

While legacy educational environments used 16-bit DOSBox Turbo C++, all code presented here adheres to standard ANSI/ISO C standards. You can compile these programs cleanly on modern Linux, Windows (MSYS2/WSL), or macOS using:

bash
> gcc -Wall -Wextra -O2 program.c -o program
> ./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 //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

SHELL
Another program that's print a variable value

c //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

CompileCompile

*For run a program:*

- Click on Run Menu - Click on Run Option

*Shortcut of Run program is* : Ctrl + F9 Key

RunRun

*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

makemake

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 locationmake location

π
TechNHIT STEM Faculty
Department of Applied Mathematics & Physics
Sample C Hello World Program | TechNHIT 10+2 STEM Lab | TechNHIT