Learn basic C programming language in just a FEW moments!

A B M Asadullah
3 min readMar 19, 2022

--

If you want to learn something, you mast face some problems as like, “what pert I should cover?”, “how many cheapter I have to complete”. For this confusing situation I made some steaps. If you complete all the steaps, you must catch easily.

Before starting:

Short Intro: In this session, we are going to understand the basic C Programming Language. At the finishing part, we will create a small software. If you carefully follow all the steps, you must understand the basic concept of C programming.

C Programming Language: C programming language is a general-purpose language developed by Dennis Ritchie & Bell Labs in 1972.

Why you should learn C: C is used for various purposes. You can develop desktop and system applications by using C. C is a middle-level language. So if you learn C you can combine the features with high-level languages (ex: python, ruby) and low-level languages (ex: assembly language).

First step:

Initial test: In this tutorial, we will test our code with an online compiler replit. To start replit C compiler click here. Maybe you will see this interface:

Replit online C compiler

Here left side our code and write side the output. if you click the Run button, the program will be run and the output will be shown “Hello, world!”.

Print the statement

Test again: Now you can change line no 4 “Hi Medium!” instead of “Hello, world!” then run. It will show “Hello Medium!”. If you see it like this, I think everything is OK. You can go to the next step.

We have to write our code inside “curly bracket” { } line 4 to 5 for this time. We can add another lines, but carefully inside { }. We will discuss every line later. Now it’s time to understand how code work.

Second Step:

Working with variables & printf() statement: Suppose x = 10, y = 5 and z = x + y. So z = 15. Here x, y and z are variables. We stored 10 in x, 5 in y and x+y = 15 in z.

Variable

In line 4, we declared x, y, and z. We used int because we are working with an integer number. In the C programming language have to declare variables first. In line 5 & 6 we assign value in x & y. Line 7 assign x + y inside z. In line 8 we printed the value of z. %d is a format specifier for decimal numbers.

Now RUN your code. you’ll see the result.

Here, you see 15 in output.

Note: Carefully see, for every line of endpoint I use a semicolon (;). It is essential to use (;). The compiler will understand the line is ended. Another, return 0. Because we don’t return anything.

User input: If you want to get input from a user you have to use scanf() statement.

In line 5: scanf(“%d %d”, &x, &y) is the format of user input for integer. We took two integer numbers. So, if you run then take the first number in the command line and press Enter. Then take the second one and press Enter and see the output. I took 10 and 50. So, the output is 60.

This is the basics of the C programming language.

--

--

No responses yet