Day 01: Introduction to C Programming

Day 01: Introduction to C Programming

·

3 min read

In order to learn C Programming, we need to understand a huge amount of stuff as we can see basic programming structure in here. We can understand what an array is, what strings are and how string and arrays are related and so much more!

Please do not be frightened by these terms just yet, I am doing this just to make you feel that is this indeed is going to be a very long course. We will understand all these via. examples straight away.

Printing "Hello World!" This is a must program that we must do in whatever language we are starting to learn. The syntax for that in C Programming is as follows:

#include<stdio.h>
void main()
{
    printf("Hello Wolrd!");
}

Output>>>

Hello World!

Explanation: We will go through each and every line of the code now:-

#include<stdio.h>

This line imports an existing library into the program so that basic C Programming functions can work properly. "#include" imports the header file(files with extension .h) and "stdio.h" means "standard input-output".

Thus, this line means that, we are importing a header file called "stdio.h" with the help of "#include" command, which will help us execute basic read-write operation in the file. Here, the file has been used to print the message "Hello World!".

void main()

This is a function that is being called. Let me make it simpler to you! Functions are special codewords or "keywords" that have a special purpose or that perform a special action.

Eg: Suppose we need to add two numbers. So, in calculator, we enter the two numbers and add the symbol "+" between them. This will simply add two numbers. Similarly, each function has it's special purpose and using a function in the code means that we are calling the function.

Here, the "main" function is being called which is the inevitable function that needs to be called in a C Program. In C Programming, at least one function need to be called and that is the "main" function. Its special purpose is to execute the code written inside it.

"void" means null. This means there is nothing. It may sound a bit confusing right now! Let me explain.

When we added the two numbers earlier in the calculator, we got a number as a result. In C Programming, it is called as a number is being returned. But here, in the main function, we can see that nothing is being returned. Whatever code is written, executes and gets completed inside it. Nothing is being sent out of the main function in order to use it later or to be stored somewhere. So, we have a "null" return type.

The brackets used after the function is important as per syntax. Usually there would be parameters inserted into it when using the function and when data is to be passed inside the function, but here we do not have anything like that. We will come across such examples gradually.

{
   ....
.........
......
}

These curly brackets or braces are used to write codes for execution.

printf("Hello World!");

As described earlier, "printf" is also a function whose special purpose is to print the data provided inside it, in the output. Here, the data provided inside it is "Hello World!". Whenever a letters are to be handled in C Programming, quotation marks ( " . . . " ) are to be used. Anything provided inside the quotation marks, will be directly printed out.

Every line of code in C Programming needs to be ended by a semicolon ( ; ). There are special cases like functions and includes that do not require them to end.

And that explains all the parts of this simple program. Hope this helps.

That is all for today! This is Arya signing off for today .

Thank You.