The C Programming Language
Presented by
Madhur Jain
220130800032
CSE(3rd Sem)
Dennis Ritchie
Introduction
C is high-level, general purpose programming
language that was developed in 1970 by
Dennis Ritchie at American Telephone and
Telegraph (AT&T) Bell Laboratories of USA.
UNIX Operating System is written in C
language.
C is Case Sensitive language. If we write C
programs in upper case letters, error will be
displayed. So always write C program in Small
Case letters.
Language C was developed in the Computer Science Research
Department of Bell Labs in Murray Hill, New Jersey
Why should I Use C?
FastExecution
Support Of Libraries
Middle Level Language
In Build Function & Operators
Easy to Learn and Use
C Character Set
C language has a set of characters which include alphabets,
digits, and special symbols used to construct words,
statements, etc.. C language supports a total of 256 characters.
1.Alphabet
(A to Z and a to z)
Character Set of C- 2. Digits
Language (0,1,2,3,4,....9)
3. Symbols
(#,$,%,^,&,*,...etc)
Keywords
Keywords are predefined or reserved words
that have special meanings to the compiler.
These are part of the syntax and cannot be
used as identifiers in the program.
A list of keywords in C or reserved words in
the C programming language are mentioned
below:
Data Type
A data type specifies the type of data that a
variable can store such as integer, floating,
character, etc.
Operators and Operand
An operator is a symbol or letter that is used to
perform specific operations on variable.
Operand is a variable on which operation is
performed by operators.
Ex.
Type of Operators
Arithmetic Ex:- +,-,*,/,%
Operators
Relational Ex:- <,>,<=,>=,!=
Logical Ex:- &&, ||,!
Increment/Decrement Ex:- x++,++x, x--
Control Statement
Control statements are used in decision
making.
These can change or transfer control from one
part of program to another part, that’s why
called as Control Statement.
Types of
Control
Statements
Decision
Case Control Loop Control
Control
Statement Statememt
Statement
Decision Making Statement
Decision-making statements decide the flow of
the program.
They are also known as conditional statements
because they specify conditions.
If the condition is true, a given block of code
will execute; if the condition is false, the block
will not execute.
IF-ELSE STATEMENT
Ex:-
#include<stdio.h>
#include<conio.h>
main()
{
int a, b;
printf(“Enter a and b”);
scanf(“%d %d”, &a, &b);
if(a>b)
{ printf(“a is greater”);
}
else
{ printf(“ b is greater”);
}
}
SWITCH STATEMENT
It is used when there is many alternatives are
given,we have to select one alternative among all
Ex:- #include<stdio.h>
#include<conio.h>
main()
{
int a;
Compiling
printf(“Enter a”); Enter A 2
scanf(“%d”,&a);
switch(a)
{
case 1:
printf(“number is one”); break; Output :-
case 2:
printf(“number is two”); break;
number is two
default:
printf(“this is default case”):
}
}
LOOP STRUCTURE
Loops in programming are used to repeat a
block of code until the specified condition is
met.
A loop statement allows programmers to
execute a statement or group of statements
multiple times without repetition of code.
C language provide three type of loop:-
1. FOR LOOP
2. WHILE LOOP
3. DO-WHILE LOOP
DO-WHILE
WHILE LOOP FOR LOOP
LOOP
While loop is used when a Do while loop is similar A for loop is used to repeat
set of statement are to be to while loop, but in do a block of statement for a
executed until condition is while loop condition is known number of time.
true. checked after execution Syntax
of loop.
Syntax:- for( initialization; condition;
Syntax increment/ decrement)
while(condition)
do {
{ ___________
{ ___________
___________ ___________
__________ }
___________
__________
___________
} __________
} while (condition)
Function
Stroustrup/PPP - Dec'13 17
Stroustrup/PPP - Dec'13 18