Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 29

History of C language

C programming language was developed in 1972 by


Dennis Ritchie at bell laboratories of AT&T
(American Telephone & Telegraph), located in U.S.A.

Dennis Ritchie is known as the founder of c language.

It was developed to overcome the problems of


previous languages such as B, BCPL etc.

Initially, C language was developed to be used in


UNIX operating system. It inherits many features of previous
languages such as B and BCPL.
Let's see the programming languages that were developed before C language.

Language Year Developed By

Algol 1960 International Group

BCPL 1967 Martin Richard

B 1970 Ken Thompson

Traditional C 1972 Dennis Ritchie

K&RC 1978 Kernighan & Dennis Ritchie

ANSI C 1989 ANSI Committee

ANSI/ISO C 1990 ISO Committee

C99 1999 Standardization Committee


Why C Language is so Important ?
Worth to Know About C Language :-
• Oracle is Written in c.
• Core Libraries of Android are Written in C
• MySQL Written in C.
• Almost every device driver is written in c
• Major part of web browser is written in c
• Unix operating system is developed in c
• C language is the world most popular programming Language

For the Student


• C is important to build Programming skill
• C covers basic features of all programming language
• Campus requirement process
• C is the most popular language for hardware dependent
programming
What is Computer?
Computer is an electronic device that takes input,
Process it and give output.

What is 0 and 1

• There are nothing like 0 and 1 in computer there is no


physical significance of 0 and 1
• Any information can be encoded as a sequence of 0 and 1.
Your Data Computer Data

ABCD 123 0101010101010101010


1010101010010100110
0101010010100101010
TEXT +_*()^ 1001001001010101010
1010011010110010101
0101010011001001010
What is File ?
File Name
•File is data bundle File Extension

Track01.mp3 Dec.jpg Raj.txt

0101010 0101010 0101010


1010101 1010101 1010101
0101010 0101010 0101010
1010101 1010101 1010101

What is Software ?
Application Software Sum.exe

System Software 0101010


1010101
0101010
This file is a software
1010101
Program and process
• set of instruction is called program
• Active state of a program is called process

Operating System
• It is a system software
• Example are DOS, Windosxp, Windows Vista, Windows 7,
Windows 8, Solaris, Macintosh, Linux, Ubuntu etc.
• It provides interface between user and machine
• Acts is a manager of the computer system
• It does process management, memory management, File
management etc.
Execution of a program….
Processor Set of
Register
0101010
MU
010101010101010100 1010101
0101010

RAM 0101010
1010101
CU 0101010
1010101

ALU Hard disk

That is exe file


Software Development in c
Headers file Sum.exe
Sum.c
010101010
#include<stdio.h> 101010101
void main() 010001010
{ Library FIle 010101010
……… Preprocessor 101010101
………
}

………..
void main()
Sum.i Linker
{
………
………
} Sum.obj
010101010
101010101
010001010
compiler 010101010
101010101
Being Learning c….
Identifiers

A to Z
a to z 1. Data type deceleration
1. Constant instructions
0 to 9 2. Input output instructions
2. Variable 3. Arithmetic's Instructions
({: “/\? 3. Keywords 4. Control instructions
><+=*
&%!

Programs
Objective
• Constant
• Variable
• Keywords
Constant…
• Any information is called constant
Data=Information=Constant

Type of Constant
Secondary
Primary Array
Integer String
Pointer
Real Union
Structure
Character
Enumerator
Integer Constant
• -55, 55, 0

Real Constant
•55.6, 24.5, 3.56, -56.0, 2.0
Character Constant
• ‘a’ ‘z’ ‘5’ ‘ ‘ ‘2’
Note:- Character constant valid only one symbol
•‘-3’ ‘3.5’ ‘saurabh’ That is not character constant
because in this constant
String included two or more symbol.
• Sequence of Characters are called String

• “Saurabh” “Mumbai”
Process Memory
Instructions
Program Consumes
Memory in RAM
a
b
Data c

• Variables are the name of memory locations


Where we store data.
Rules of Variable
•Variable name is any combination of alphabets,
Digits and underscore.
• A valid variable name is cannot start with digit
Keywords
• Identifier:- smallest identifying unit of the programs.
• Predefined words
• Reserved words
• There are 32 keywords in c language

auto double goto signed unsigned


break default if sizeof voide
case enum int static volatile
char else long struct while
continue extern register switch
const for return typedef
do float short union
Data type Declaration
Instructions
• Instructions:- Program statements are called
Instructions, Instruction are commands
• Type of instructions
--- Data type declaration instruction
--- Input Output Instruction
--- Arithmetic Instructions
--- Control Instruction
Data type
• int
Which data type included keywords
• char Are called primitive data type
• float
• double
• void
Primitive Data type
auto double goto signed unsigned
break default if sizeof void
case enum int static volatile
char else long struct while
continue extern register switch
const for return typedef
do float short union
Declaration Statements
a b
int a,b=5;
k
float k;
ch m
char ch,m;
d1
double d1;
Input Output Instructions
Standard Input / Output device
• Keyboard is standard input device
• Monitor is standard output device.
printf()
• printf() is not a keyword
• printf() is a predefined function
Two types of messages
• printing text as it is
• printing value of expression or value of variable
First Program
#include<stdio.h> // include header file in program
#include<conio.h>// used to include console input output header file
main() // main is the predefined function, here program body start
{
clrscr();// used to clear the screen it’s a also predefined function.
printf(“Welcome to First Program”); // used to print the message
getch(); // used to take a character from keyboard , it’s a also predefined function
}
List of Escape Sequences in C
Escape Sequence Meaning
\a Alarm or Beep
\b Backspace
\f Form Feed
\n New Line
\r Carriage Return
\t Tab (Horizontal)
\v Vertical Tab
\\ Backslash
\' Single Quote
\" Double Quote
\? Question Mark
\nnn octal number
\xhh hexadecimal number
\0 Null
Program
#include<stdio.h>
#include<conio.h>
main()
{
clrscr();
printf(“Welcome to\n”);
printf(“Saraswati Computer Classes”);

getch();
}
Program gotoxy()
#include<stdio.h>
#include<conio.h>
main()
{
clrscr();
gotoxy(40,13);
Printf(“Akash”);
getch();
}
Program of printing variable
The format Specifire can be %d (integer), %c (character),
%s (string), %f (float) %lf(double) etc.

#include<stdio.h> #include<stdio.h>
#include<conio.h> #include<conio.h>
main() main()
{ {
int a=5,b=6; int a=5,b=6;
clrscr(); clrscr();
Printf(“a=%d\n”,a); Printf(“sum of %d and
Printf(“b=%d”,b); %d is %d”,a,b,a+b);
getch(); getch();
} }
scanf()
The format Specifier can be %d (integer), %c (character),
%s (string), %f (float) %lf(double) etc.

scanf() function
The scanf() function is used for input. It reads
the input data from the console.
scanf("format specifier", variable address);

Program to print cube of given number


#include<stdio.h>
#include<conio.h>
int main(){
int number;
printf("enter a number:");
scanf("%d",&number);
printf("cube of number is:%d ",number*number*number)
;getch();
}
C Operators
• Arithmetic Operators
• Relational Operators
• Shift Operators
• Logical Operators
• Bitwise Operators
• Ternary or Conditional Operators
• Assignment Operator
• Misc Operator
Precedence of Operators in C
Category Operator Associativity
Postfix () [] -> . ++ - - Left to right
Unary + - ! ~ ++ - - (type)* & Right to left
sizeof
Multiplicative */% Left to right
Additive +- Left to right
Shift << >> Left to right
Relational < <= > >= Left to right
Equality == != Left to right
Bitwise AND & Left to right
Bitwise XOR ^ Left to right
Bitwise OR | Left to right
Logical AND && Left to right
Logical OR || Left to right
Conditional ?: Right to left
Assignment = += -= *= /= Right to left
%=>>= <<= &= ^=
|=
Comma , Left to right
Comments in C
•Single Line Comments
•Multi Line Comments

Single Line Comments


#include<stdio.h>
int main(){
//printing information
printf("Hello C");
return 0;
}

Mult Line Comments


#include<stdio.h>
/* int main(){
code /*printing information
Multi Line Comment*/
to be commented printf("Hello C");
*/ return 0;
}
List of Constants in C
Constant Example

Decimal Constant 10, 20, 450 etc.

Real or Floating-point Constant 10.3, 20.2, 450.6 etc.

Octal Constant 021, 033, 046 etc.

Hexadecimal Constant 0x2a, 0x7b, 0xaa etc.

Character Constant 'a', 'b', 'x' etc.

String Constant "c", "c program", "c in


javatpoint" etc.

You might also like