C PROGRAMMING Notes
C PROGRAMMING Notes
C PROGRAMMING Notes
WHAT IS PROGRAMMING?
Programming is the process of creating instructions for a computer to execute. It involves writing code in
a specific programming language to solve problems, automate tasks, or develop software applications.
Through programming, developers can manipulate data, control hardware, and build complex systems
that power the digital world.
C LANGUAGE :
C is a high-level, general-purpose programming language initially developed by Dennis Ritchie at Bell Labs
in the early 1970s. It is one of the most influential programming languages and has greatly influenced
many other programming languages, including C++, Java, Python, and many more.
FEATURES OF C LANGUAGE :
1. Simplicity: C is designed to be simple and straightforward. It has a clear and concise syntax, making
it easy to read and write code.
2. Portability: C programs can run on different types of computers with minimal changes. This means
that once you write a C program, it can work on various machines without much hassle.
3. Modularity: C allows you to break down your program into smaller, manageable parts called
functions. These functions can be reused in different parts of your program, making it easier to
organize and maintain your code.
4. Efficiency: C is known for its efficiency in terms of both execution speed and memory usage. It
allows you to write programs that run quickly and use system resources effectively.
5. Flexibility: C provides a wide range of operators, data types, and control structures, giving you the
flexibility to express your ideas and solve problems in different ways.
6. Low-Level Features: C gives you direct control over the computer's hardware, allowing you to
manipulate memory and perform low-level operations when needed.
7. Extensibility: C can be easily extended through libraries and other languages like assembly
language. This allows you to add new features to your programs or optimize performance as
needed.
SYNTAX OF C PROGRAMMING :
1. Preprocessor Directives (Optional):
• Instructions for the compiler before actual compilation (e.g., including header files).
• Common example: #include <stdio.h> which includes the standard input/output library.
2. Main Function:
int main()
// Code to be executed
return 0;
3. Variables:
• Declaration specifies data type and variable name (e.g. int age;).
• Common data types include int (integers), float (decimals), char (single characters), etc.
4. Statements:
Define :
1) It is a name of storage space which is used to store data.
2) It’s value is changeable.
3) It always contains last value stored to it.
4) It’s always declared with data types.
Variable Declaration :
Variable declaration in C involves specifying the data type and name of the variable. It allocates
memory for the variable. Optionally, you can also initialize the variable with an initial value. Here's a
brief example:
Variable Initialization :
Variable initialization in C involves assigning an initial value to a variable at the time of declaration.
This sets the variable to a specific value from the start.
• data_type: Specifies the type of data that the variable can hold, such as int, float, char, etc.
• variable_name: The name chosen by the programmer to identify the variable. It follows the
rules for variable naming conventions in C.
example :-
int age = 25; // Initializing an integer variable 'age' with an initial value of 25
float height = 5.9; // Initializing a floating-point variable 'height' with an initial value of 5.9
char grade = 'A'; // Initializing a character variable 'grade' with an initial value of 'A'
You can also initialize multiple variables of the same data type on the same line:
Define :
Example :-
int roll = 201;
float marks = 85.6;
char grade = ‘A’;
Define :