Webberhub.com Logo
webberhub.com Intro

Say Hello World - C Programming Lesson 01


Say Hello World - C Programming Lesson 01

This lesson show the most basic code of hello world example and full explanation of whole code used for hello word basic program in c programming. That will be vary impotent for the programming beginners.



Say Hello World in C Programming

If you need to follow this lesson correctly, First follow the previous lesson of Introduction to Programming with C language and install necessary application for compile and run C programs.

The C programming language is the Structured Programming Language. This means the program must be programmed in a certain order.

So, C language is case sensitive. That mean, you should consider the English capital and lowercase letters in programming.

Now we are getting into the C language using a simple program.

C Basic program hello world

First, Type the above code in the coding window of your compiler software.

Let us explain each of parts in this simple program.

#include<stdio.h> 

This code section allows us to import files with prefabricated code parts into our program. It allows us to more easily programmed.

Also, the header file stdio.h enables the Basic Input / Output operation of our program.

int main()

This code section represents the mainly used function in C.

Function is an important term used in C. Buy using function we can write complex code into sections and easily manage it.

I hope to talk about functions in detail in the future. for now let us understand the main function currently used.

In the C programing, hundreds of different functions can be written, but there must be one main function.

Here we used only the main function. It gives the computer an idea of what part of the code should be read first.

The parentheses "( )" used here to identify it as function.

This code uses int to indicate that the main function returns is integer type.

Every time a function used the brackets "{ }" are split it into separate code sections.

printf("hello world" );

Here shows the code section we are going to perform. This function basically a result is displayed on the screen. The printf function used to get the output. It is a standard output command in C.

The partition to be printed on the screen under printf must be written in parentheses. By that, computer recognizes the written part as a text.

At the end of each code line Semicolon " ; " must be used to notify the computer that the end of the line.

return 0;

Note that the main function used the code int for indicate the return type is integer. But in this code, basically anything is not printed on the screen and also nothing is sent out.

Therefore, used return 0;. It is known that nothing is returned.

It is not compulsory a function must always return an int or such a data type. The data type will be explained in detail in the future.

If a function does not return anything, it can be called a void.

Compiling Source Code and Getting Output

Now you can get the output of the program successfully coded. for that, this code needs to be compiled. 

For that you need to build the code according to the compiler you are using.

The following shows the process of doing it using C-free software.

Build -> Run

 

C code build and run

 

C simple program

 

So, We can easily compile the code by clicking on the Run button or by pressing F5 key on the keyboard.

If it compiled correctly, You can see following output.

 

C program output

 

If the program is compiled correctly and Run it, you can see a .exe file with that your program name in it where you saved your source code.

It is the application that you created successfully in the program you wrote.

You can simply run your program by double clicking on it.

 

C compiled program file location

 

We can learn basics of C programming in next lesson.

 


Related Posts..