0% found this document useful (0 votes)
5 views10 pages

c notes

C is a widely used general-purpose programming language developed by Dennis Ritchie in 1972, known for its efficiency and flexibility. It is utilized in various areas such as operating systems, embedded systems, and game development, and features a simple syntax, structured programming, and low-level access to memory. Learning C provides a strong foundation for understanding other programming languages due to its influence on modern languages like C++, Java, and Python.

Uploaded by

sivarekha68
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views10 pages

c notes

C is a widely used general-purpose programming language developed by Dennis Ritchie in 1972, known for its efficiency and flexibility. It is utilized in various areas such as operating systems, embedded systems, and game development, and features a simple syntax, structured programming, and low-level access to memory. Learning C provides a strong foundation for understanding other programming languages due to its influence on modern languages like C++, Java, and Python.

Uploaded by

sivarekha68
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

C PROGRAMMING – BASIC NOTES

1. Introduction to C Programming
C is one of the most important and widely used programming languages in the world. It is a
general-purpose programming language used for developing system software, application
software, and embedded systems.

The C programming language was developed by Dennis Ritchie in 1972 at Bell Laboratories.
It was originally created to develop the Unix operating system.

C is known for its efficiency, flexibility, and powerful features. Many modern programming
languages such as C++, Java, and Python are influenced by the C language.

C is often called the mother of many programming languages.

Uses of C Language

C language is used in many areas including:

 Operating system development


 Embedded systems
 System software
 Game development
 Compilers
 Database systems

Because of its speed and efficiency, C is still widely used in software development.

2. Features of C Programming
C language has many features that make it powerful and popular.

1. Simple Language

C has a simple syntax and a small set of keywords, making it easy to learn.

2. Structured Programming

C follows a structured programming approach. Programs are divided into functions, making
them easier to understand and maintain.
3. Portable

Programs written in C can run on different computers with little or no modification.

4. Efficient and Fast

C programs run very fast because they are close to machine-level operations.

5. Rich Library

C provides many built-in functions through standard libraries.

6. Low-Level Access

C allows direct access to memory using pointers.

3. Structure of a C Program
A C program contains several sections.

Basic structure of a C program:

#include <stdio.h>

int main()
{
printf("Hello World");
return 0;
}

Explanation

#include <stdio.h>

This is a header file that contains input and output functions.

main() function

Execution of every C program begins from the main function.

printf()

This function is used to display output on the screen.


return 0

Indicates that the program executed successfully.

4. C Character Set
C language uses a set of characters to write programs.

The C character set includes:

1. Alphabets

A to Z
a to z

2. Digits

0 to 9

3. Special Symbols

Examples:


o
 /=<>(){}[];:#%

These characters are used to form variables, keywords, constants, and expressions.

5. Keywords in C
Keywords are reserved words that have special meaning in the C programming language.

Examples of C keywords:

 int
 float
 char
 if
 else
 while
 for
 return
 break
 continue

These keywords cannot be used as variable names.

Example:

int number;
float salary;

6. Variables in C
A variable is a memory location used to store data.

Each variable has:

 Name
 Data type
 Value

Syntax:

datatype variable_name;

Example:

int age;
float marks;
char grade;

Example program:

#include <stdio.h>

int main()
{
int age = 20;
printf("Age is %d", age);
}

Here %d is a format specifier used to print integer values.


7. Data Types in C
Data types specify the type of data that a variable can store.

Basic Data Types

Data Type Description


int Stores integer values
float Stores decimal values
char Stores single characters
double Stores large decimal values

Example:

int a = 10;
float b = 5.5;
char c = 'A';

Derived Data Types

 Arrays
 Pointers
 Structures
 Unions

Void Data Type

Used when a function does not return any value.

8. Operators in C
Operators are symbols used to perform operations on variables and values.

1. Arithmetic Operators

Used for mathematical calculations.

Examples:

+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus

Example:

int a = 10;
int b = 5;
int c = a + b;

2. Relational Operators

Used for comparisons.

Examples:

== Equal to
!= Not equal
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal

3. Logical Operators

Used to combine conditions.

Examples:

&& Logical AND


|| Logical OR
! Logical NOT

4. Assignment Operators

Used to assign values.

Examples:

= Assign
+= Add and assign
-= Subtract and assign

9. Control Statements
Control statements determine how the program executes.

If Statement
Used to test a condition.

Example:

if(age >= 18)


{
printf("Eligible to vote");
}

If–Else Statement
if(mark >= 50)
{
printf("Pass");
}
else
{
printf("Fail");
}

Switch Statement

Used for multiple choices.

Example:

switch(day)
{
case 1:
printf("Monday");
break;

case 2:
printf("Tuesday");
break;
}

10. Looping Statements


Loops are used to repeat a block of code multiple times.

For Loop

Example:

for(int i = 1; i <= 5; i++)


{
printf("%d", i);
}
While Loop

Example:

int i = 1;

while(i <= 5)
{
printf("%d", i);
i++;
}

Do-While Loop

Example:

int i = 1;

do
{
printf("%d", i);
i++;
}
while(i <= 5);

11. Functions in C
A function is a block of code that performs a specific task.

Functions help in:

 Reducing code repetition


 Improving readability
 Making programs easier to maintain

Example:

#include <stdio.h>

void greet()
{
printf("Hello");
}

int main()
{
greet();
}
Types of functions:

1. Library functions
2. User-defined functions

12. Arrays in C
An array is a collection of elements of the same data type.

Example:

int numbers[5];

Example program:

int marks[3] = {80, 85, 90};

Arrays help store multiple values in a single variable.

13. Pointers in C
A pointer is a variable that stores the memory address of another variable.

Example:

int a = 10;
int *p;
p = &a;

Pointers are very powerful features in C and are used for:

 Dynamic memory allocation


 Passing arguments to functions
 Working with arrays

14. Advantages of C Language


 Fast execution
 Efficient memory usage
 Portable programs
 Powerful programming features
 Used in system programming

15. Conclusion
C is one of the most fundamental programming languages. It provides low-level memory access
and efficient execution, making it suitable for system programming and embedded systems.

Even today, C continues to be widely used in operating systems, compilers, and hardware
programming. Learning C provides a strong foundation for understanding other programming
languages.

You might also like