Published on

Hollowly hello world in C

Authors
  • avatar
    Name
    Ridha Majid
    Twitter
cover

Writing a Hello World program is essential for anyone stepping into learning a new programming language. Every language has its own writing style, syntax, and structure, and 'hello world' is often the first introduction to understanding these elements. In this article, we’ll talk about how to write a Hello World program in the C language.

Here's the finish program look like.

    #include  <stdio.h>

    int  main(void)
    {
    printf("Hello world \n");
    }

So there are some steps

Open the terminal or command prompt

Create a new project folder, mkdir

mkdir project-hello

navigate the folder project use the cd

cd project-hello

create a new project file use the code

code hello.c

And now let's we write the hello world program together.

	// We input the important header file, should be spell same.
	#include  <stdio.h>

	// main function, unlike python. having a main function in C is mandatory. as my knowledge.

	int  main(void)
    {
    // we use a printf() to print the "Hello-world", *** must be use a double-quotation ***
    // for is for newline character ( \n ).
    // you can replace the "hello world" anything, for example "Hello girraffe".

    printf("Hello world \n");
    }

And now let's compile the programme.

Open the terminal or command prompt.

navigate the folder project use the cd

cd project-hello

Compile the Program use:

clang hello.c -o hello
  • 'clang' is for compile
  • 'hello.c' is the file name
  • '-o' is stand for output
  • 'hello' for the name our executable program.

Press enter or return, if there are no warning, means the program succeffully compailed and let's we run the program.

./hello
  • And you should see your the output, Hello world
Hello world