Introduction To C Part 2.

Tifu Kelison Tifu Kelison
2 min read

Hi there, in Part one of the series of the introduction to C, I talked about the tools you need to get started with C. In this article, I'll be walking you through the basic C codes. So with that said, consider the lines of code below.

C Code

#include<stdio.h>
int main(void) {
printf("This is my first C program");
return 0;
}

Don't worry if you don't understand what you're seeing yet. I'll be explaining each line of code below.

Line 1: #include<stdio.h> is a header file library. Basically what it does is that it imports all the necessary functions you need in your program. For example, the printf() statement used above is a function and it is being imported from the header library file. So in simple terms, your program will not run if you don't have the necessary library files.

Line 2: int main(void) { // code } Every C program has a primary function that must be named main. This is where any code that you want to execute goes into. It usually controls program execution by directing the calls to other functions in the program.

Line 3: printf() is a function that lets you output/print output on the screen. As I said earlier, the printf() function will not work without including the header library file into the top of your file.

Line 4: return 0; means that the function doesn't return any value. It is used when the void return type is used with the function. It is not mandatory though.

And don't forget to close the curly braces when done with typing your code {}. Notice how I ended the Line 3 with a semicolon. That is how all lines of code in C must end. Now I want you to try that in your text editor and you let me know how it goes in the comments.

Until next time.

Peace.

0
Subscribe to my newsletter

Read articles from Tifu Kelison directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Tifu Kelison
Tifu Kelison

I am a Graphic Designer and Front-end developer and UI Designer(still in process) from Cameroon. I am the founder and CEO of the Design Archive. I love to write and as it turns out, hashnode is just the community I needed to start doing that. I at the time of writing this bio, I'm in my first year of university that's why you see writing articles about C. If you ever what to chat, feel free to hit me up on any social media platform.