C is one of the most powerful and widely used programming languages. Before we dive into coding, let’s understand some fundamental concepts.
A program is a set of instructions that a computer executes to perform a specific task. These instructions are written in a programming language and converted into machine code that the hardware understands. Think of it as a recipe—each step tells the computer what to do, just like a recipe tells a cook how to prepare a dish.
Computers operate using hardware, which includes components like the CPU, memory, and storage devices. However, hardware only understands machine language, a series of binary codes (0s and 1s). Writing programs in machine language is incredibly difficult for humans.
To make programming easier, assembly language was introduced. It uses mnemonics (short commands like ADD, SUB, MOV) that correspond to machine instructions. Still, writing programs in assembly is complex.
To further simplify programming, high-level languages like C were developed. These languages use English-like syntax and are easier to read and write. A compiler translates high-level language code into machine code.
#include <stdio.h> // Header file
int main() { // main function
printf(“Hello, World!”); // Output statement
return 0; // Return statement
}
#include <stdio.h>
): Used to include standard functions like printf()
.main()
): Every C program starts execution from this function.{}
: Define the block of code.printf("Hello, World!");
): Perform actions.return 0;
): Ends the program.A variable is a named memory location that stores data.
_ (Underscore)
.1num
is invalid).int
, return
, etc.).age
and Age
are different).Valid variable names: age
, num_1
, count123
Invalid names: 123var
, int
, float-value
int
, float
, return
).int
– Integer typefloat
– Floating point type or decimal typechar
– Character typeprintf()
FunctionUsed to display output on the screen:
printf(“Welcome to C Programming!”);
Tokens are the smallest elements in a C program, including:
int
, return
)10
, 'A'
)+
, -
, *
){}
, []
, #
C has 32 reserved keywords, including int
, char
, void
, return
, if
, else
, switch
, for
, while
, and do
.
(Don’t worry about remembering all of them now—we will learn each in upcoming lessons.)
This was just a basic introduction to C programming. In upcoming lessons, we will explore each concept in detail. Stay tuned