C Tutorial for Beginners – Step by Step Guide

C language is a general-purpose programming language that was first developed in 1972. It is a professional programming language used to write UNIX application programs. You can use C for writing language compilers, operating systems, text editors, language interpreters, and databases. This blog can help you understand C language structures like syntax, data types, variables, strings, and more if you are new to the C programming language.

C Tutorial for Beginners

Let us understand some of the key components of the C programming language!

1. Setting up the environment

Before you start using the C programming language, you will have to set up an environment. It means that you need the necessary hardware and software for using the language. The two most crucial software you need to install on your computer for using C are text editor and C compiler.

The text editor helps you type out your program. You can choose amongst plenty of text editors like Windows, Notepad, and EMACS. The files created on text editors contain the program source. Hence, these are called the source files. These files have a C extension in their name and are saved on the computer. 

The code that you write through the C programming language must be converted into text that the computer can understand. This C compiler does this conversion of text.

2. How to write, compile and execute the program?

  • You must also know that the first line of the program contains a preprocessor command <stdio.h>. 
  • In the next line, we use the main function int main() for executing the program.
  • The compiler ignores the /*…*/ next line and adds it as an additional comment in the program.
  • Another line printf(…) function in C language displays the text “Hello, World!” on the screen. 
  • The next step is to open the text editor, copy this code and save the files.
  • Next, you need to go to the directory where the file is saved and type gcc hello.c to compile the code. 
  • The next step is to execute the program by typing a.out.
  • You will now see the text “Hello World” on the screen, which means your program has been executed.

3. C Syntax

Now, you have to understand the syntax of the C programming language. It comprises five tokens.

  1. Semicolons:- We use semicolons to end a line in C language. We terminate each line in C with a semicolon.
  2. Identifiers:- The purpose of identifiers in C language is to identify different variables, functions, and user-defined items in the program. We can start an identifier with an alphabet between A to Z or any digit between 0 to 9. We can also use underscores to start the name of an identifier. However, you cannot use punctuations or special characters in the program.
  3. Comments:- Comments in the C programming language act as helping words. We start a comment with the/* sign and end it with the */ sign.
  4. Keywords:- These are reserved keywords in the C programming language that cannot be used as constants or variables. Some of the keywords are auto, else, switch, register, long, typedef, break, and case. You can easily find a list of all keywords in the C language online.
  5. Whitespaces:- Whitespaces in C program denotes blanks, tags, and comments. The purpose of whitespace is to separate the two parts of a sentence.

4. C Data Types

Data types in the C language are used to declare various types of variables of functions. The following are the different data types in C:

  1. Basic:- These are arithmetic data types that are further divided into integer and floating data types. These data types are used to define values and their storage sizes.
  2. Enumerated:- Similar to basic data types, the enumerated data types are also arithmetic. However, they can only define variables that have a definite integer value.
  3. Derived:- There are different types of derived data types – pointer, array, structure, union, and function types.
  4. Void:- The void data types indicate that no value is available.

Popular Courses & Articles on Software Engineering

5. Variables, Constants, and Literals in C

Variables in programming languages are the names given to a definite storage area in which we can make changes later. For example, there are different variable types in the C language that determine the storage size and the values which can be stored in that area.

Constants or literals in the C programming language are the fixed values that you cannot alter once the program is executed. The following are the different types of literal in C.

  • Integer Literals:- These are constant decimal, octal, or hexadecimal values.
  • Floating-point Literals: These literals comprise integer values, decimals, fractions, and exponent parts.
  • String Literals:- These literals contain plain and universal characters and escape sequences. The string literals are prefixed and suffixed by double-quotes.
  • Character Constants:- These are plain characters, universal characters, or escape sequences. Character constants are enclosed in single quotes.

6. Operators

The operators in C  language are described as symbols that facilitate the compiler to carry out mathematical or logical functions. The following are the different types of operators in the C language:

  1. Arithmetic Operators:- The arithmetic operators are used to carry out arithmetic functions like addition, subtraction, multiplication, division, modulus operator, increments, and decrements between two operands.
  2. Relational Operators:- These operators are used to find out the relation between two operands. They are used to confirm if the value of one operand is greater or lesser than the other. It then checks if the value is correct.
  3. Bitwise Operators:- These are binary operators that work on bits and perform the bit-by-bit operation. You can see the truth tables to use the bitwise operators. We use the & binary operator to copy a bit if the result exists in both operands. The | operator copies the bit if the result is present in any operand.
  4. Logical Operators: To use logical operators, we assume A’s value as 1 and B’s as 0. The Logical AND operator checks whether both the operands are non-zero. The Logical OR operator checks if any one of the operands is zero. The Logical NOT Operator reverses the logical state of the operands.
  5. Assignment Operators:- These are used to carry out various activities. We use the = operator to assign values of right-side operands to the left-side operands. The += operator adds the value of the right operand to the left operand and declares the result to the left operand.

Learn Software Development Courses online from the World’s top Universities. Earn Executive PG Programs, Advanced Certificate Programs or Masters Programs to fast-track your career.

7. C Functions

In C language, we understand functions as a group or block of statements written to perform a specific task. We can call a function multiple times. The following are the different parts of a function:

  • Return type:- The function returns a value through the return data type.
  • Function name:- The real name of the function is termed the function name. When combined with a parameter list, it forms the function signature.
  • Parameters:- When we invoke a function, we must pass a value to the parameters that act as placeholders. These are optional.
  • Function Body:- The set of statements that explain what a function has to do is called the function body.


According to Statista, C is one of the most popular programming languages worldwide. It is often referred to as an evergreen language because it is simple to understand. C is a mid-level or base programming language. You must know the C language basics before you learn more complex programming languages like Java, Python, or HTML. If you wish to learn the fundamentals of the C programming language, you can consider the Executive PG Program in Software Development on upGrad.

What are variables in the C language?

Variables in the C language are the names of storage areas. We can also understand them as memory locations that store data that can be altered later. The variables are denoted by alphabets, digits, or an underscore. We cannot add whitespace within the name of the variable.

How do we set up an environment for the C programming language?

Before you start programming, you need software to set up the environment. You require a text editor and a C compiler for this. The text editor is needed to write down the program. We use the C compiler to convert the normal text into computer language.

What are strings and arrays in the C programming language?

Strings in C language are a set of characters. They are also defined as an array of characters and terminated by a null (''). We can declare strings in the C programming language through char array or string literal.

Want to share this article?

Prepare for a Career of the Future

Leave a comment

Your email address will not be published. Required fields are marked *

Our Best Software Development Course

Get Free Consultation

Leave a comment

Your email address will not be published. Required fields are marked *

Get Free career counselling from upGrad experts!
Book a session with an industry professional today!
No Thanks
Let's do it
Get Free career counselling from upGrad experts!
Book a Session with an industry professional today!
Let's do it
No Thanks