0% found this document useful (0 votes)
86 views

Basic of C Language

C programming language was developed in 1972 by Dennis Ritchie at Bell Laboratories to overcome limitations of previous languages like B and BCPL. It was initially created to be used in the UNIX operating system. C inherits features from previous languages but also introduced new concepts. It has become one of the most widely used programming languages due to its efficiency and ability to produce executable code for various hardware platforms.

Uploaded by

Rishabh Pandey
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
86 views

Basic of C Language

C programming language was developed in 1972 by Dennis Ritchie at Bell Laboratories to overcome limitations of previous languages like B and BCPL. It was initially created to be used in the UNIX operating system. C inherits features from previous languages but also introduced new concepts. It has become one of the most widely used programming languages due to its efficiency and ability to produce executable code for various hardware platforms.

Uploaded by

Rishabh Pandey
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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

0101010101010101010
ABCD 123 1010101010010100110
010101001010010101
010010010010101010
TEXT +_*()^ 1010100110101100101
010101010011001001
010
What is File ?
File
•File is data bundle Name File
Extension
Track01.mp Dec.jp Raj.txt
3 g
0101010 0101010 0101010
1010101 1010101 1010101
0101010 0101010 0101010
1010101 1010101 1010101

What is Software ?
Application Software Sum.ex
e
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
01010101010101010 1010101
0 0101010

RAM 0101010
1010101
CU Circuit that reads
0101010
1010101
Instructions and
decode it

ALU Hard disk

That is exe file

Responsible for all


arithmetical and
calculations
Software Development in c
Headers Sum.ex
Sum. file 010101010
e
c
101010101
#include<stdio.h> 01000101
void main() 001010101
{ Library FIle
Preprocessor 010101010
……… 1
………
}
………..
void main()
Sum. Linker
{
……… i
………
} Sum.ob
010101010
j
101010101
01000101
001010101
compiler 010101010
1
Being Learning c….
Identifier
s
A to Z
1. Data type deceleration
a to z instructions
1. Constant
0 to 9 2. Input output instructions
2. Variable
({: “/\? 3. Keywords
3.
4.
Arithmetic's Instructions
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 included
String 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;
c m
char ch,m; h
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()
functionfunction is used for input. It reads
The scanf()
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*numb
er);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