SlideShare a Scribd company logo
C Programming
language
Overview
§
Computer System
§
Architecture of Computer System
§
Need of C Programming Language
§
History of C
§
Tokens in C
Computer System
§
Is a collection of related Components that have all
been design to work together Smoothly
§
Bits and Byte
§
Use of Computer
Internal Architecture of Computer
Types of Software
Communication between User
and Machine
User want to interact with machine but
machine only knows language in the
form of 0’s and 1’s i.e. Bit (Binary
Language)
User Machine
•
So Binary language is also known as Machine level language but it is difficult to
understand because it is in the form of bits.
•
So user want language that is close to user and we know it as High level language .
•
High level language is just like English language, all instructions are in friendly
approach.
Need of Translator
•
Computer only understands Binary language and user only understands
High level language.
•
So there are two types of translators
1)Compiler
2)Interpreter
Difference between Compiler and Interpreter
Compiler Interpreter
Compiler Takes Entire program as
input
Interpreter Takes Single instruction
as input .
Intermediate Object Code is
Generated
No Intermediate Object Code is
Generated
Conditional Control Statements are
Executes faster
Conditional Control Statements are
Executes slower
Memory Requirement : More
(Since Object Code is Generated)
Memory Requirement is Less
Program need not be compiled
every time
Every time higher level program is
converted into lower level program
Errors are displayed after entire
program is checked
Errors are displayed for every
instruction interpreted (if any)
Example : C Compiler Example : BASIC
8
History of programming language
low-level languages:-
•
Those are machine languages and machine-
dependent.
•
Fully binary, and symbolic so not code efficient.
•
Such languages are-
§Fortran
§Algol 60
§Cobol
§Basic
§Simula 67
§Pascal
Need of C Language
C is called as Middle level language.
§
Behaves as High Level Language through Functions - gives a
modular programming
§
It gives access to the low level memory through Pointers
§
As its a combination of these two aspects, its neither a High
Level nor a Low level language ,so C is Middle Level
Language.
History of C Language
•
Developed at Bell Laboratories in 1972 by Dennis Ritchie.
•
Features were derived from earlier language called “B” (Basic
Combined Programming Language – BCPL)which is developed
by Ken Thompson in 1970’s.
•
Invented for implementing UNIX operating system
C Programming Basics
Each language is made up of two parts,
§
Vocabulary
§
Grammar
In programming language,
§
Vocabulary means Tokens
§
Grammar means Syntax
C Tokens
– Basic buildings blocks which are constructed together to
write a C program.
– Identifiers
– Variables
– Constants
– Character Set
– Keywords
– Data types
– Operators
Identifier
• Unique name given to identify units
• E.g.int Num
Num is identifier given to integer variable
Variable
•
Name given to the location in a memory which is used to hold
the value.
•
The value of the C variable may get change in the program.
•
C variable can hold values like integer, float point, character
etc.
•
E.g. Age, height etc.
Constant
•
Name given to the location in a memory which is used to hold
the value .
•
Values can not be modified by the program once they are
defined.
•
Constant might be belonging to any type like integer, float
point, character etc.
•
E.g. Pi value=3.14
Character set
C language have collection of different character set which contain
Alphabets A-Z, a-z
Digits 0-9
Special symbols !,@,#,$,%,^,&,*,(,),_,+,=,-
Keywords
• Keywords are pre-defined words in a C compiler.
• Also known as Reserved words.
• Each keyword is meant to perform a specific function in a C
program.
• Since keywords are referred names for compiler, they can’t be
used as variable name.
• C language have 32 keywords.
Keywords
Datatypes
Range of Data type
Declaration of Variable
Syntax- Data_type variable_name;
•
Integer data types:
§
Keyword int is used for declaring the variable with integer type.
§
For example: int var1;
•
Floating data types:
§
Variables of floating types can hold real values(numbers).
§
Keywords either float or double is used for declaring floating type
variable.
§
For example: float var2;
•
Character types:
§
Keyword char is used for declaring the variable of character type.
§
For example: char var4='h';
Operators in C
• Symbol that tells the compiler to perform specific
mathematical or logical operations.
• Types of operators-
§
Arithmetic Operators
§
Relational Operators
§
Increment Operator
§
Decrement Operator
§
Logical Operators
§
Conditional Operator
Arithmetic Operators
•
Used to perform arithmetic operations.
Operator Description Example(A=10,B=20)
+ Adds two operands A + B will give 30
- Subtracts second operand from the first A - B will give -10
* Multiplies both operands A * B will give 200
/ Divides numerator by de-numerator B / A will give 2
% Modulus Operator and remainder of after an
integer division
B % A will give 0
Relational Operators
Operator Description Example(A=10,B=20)
== Checks two operands are equal or not, if yes then condition
becomes true.
(A == B) is not true.
!= Checks two operands are equal or not, if values are not
equal then condition becomes true.
(A != B) is true.
> Checks left operand is greater than right operand, if yes
then condition becomes true.
(A > B) is not true.
< Checks left operand is less than right operand, if yes then
condition becomes true.
(A < B) is true.
>= Checks left operand is greater than or equal to the right
operand, if yes then condition becomes true.
(A >= B) is not true.
<= Checks left operand is less than or equal to right operand, if
yes then condition becomes true.
(A <= B) is true.
Logical Operators
•
They evaluate each operation result in terms of 0 and 1.
•
Logical Operators are three type as
– AND- (&&)
– OR-(||)
– NOT-(!)
Increment Operator(++)
•
Increment operator increase the value of subsequent by 1. value may be
increase according to the programmer.
•
Increment operator are two types as follows :
– Post increment
– Pre increment
Post increment Pre increment
A=10
B=A++
A=11 A=10
B=++A
A=11
B=10 B=11
Decrement Operator(--)
•
Decrement operators decrease the value to one, two and so on.
•
Two type as,
– Post decrement
– Pre decrement
Post Decrement Pre Decrement
A=10
B=A--
A=9 A=10
B=--A
A=9
B=10 B=9
Conditional Operator(?:)
•
Ternary operator
•
Syntax:
condition ? result1 : result2
•
If the condition is true, result1 is returned else result2 is
returned.
Largest no among 3 no's using
conditional Operator
     Max=(A>B) ? ((A>C)?A:C) : ((B>C)?B:C) 

More Related Content

PDF
Introduction to c++ ppt
PPTX
Variables in C++, data types in c++
PPT
Operators in C++
PPTX
Increment and Decrement operators in C++
PPTX
Conditional statement in c
PPTX
Operators and expressions in c language
PPT
User defined functions in C programmig
PPTX
Variables in C and C++ Language
Introduction to c++ ppt
Variables in C++, data types in c++
Operators in C++
Increment and Decrement operators in C++
Conditional statement in c
Operators and expressions in c language
User defined functions in C programmig
Variables in C and C++ Language

What's hot (20)

PPT
Structure and union
PPTX
Pointer in c
PPTX
Operators in C & C++ Language
PPTX
DOCX
C – operators and expressions
PPTX
Pointer in c program
PPTX
Operators and expressions
PPTX
Decision making and looping - c programming by YEASIN NEWAJ
PPTX
Pointer in c
PPTX
What is Exception Handling?
PPTX
Presentation on pointer.
PPTX
Top down parsing
PPTX
Structure in C language
PPTX
Break and continue in C
PPTX
Introduction to Selection control structures in C++
PPT
C++ Language
PDF
Constructors and destructors
PPTX
fundamentals of c
PPTX
Pointer in C++
PDF
C++ tokens and expressions
Structure and union
Pointer in c
Operators in C & C++ Language
C – operators and expressions
Pointer in c program
Operators and expressions
Decision making and looping - c programming by YEASIN NEWAJ
Pointer in c
What is Exception Handling?
Presentation on pointer.
Top down parsing
Structure in C language
Break and continue in C
Introduction to Selection control structures in C++
C++ Language
Constructors and destructors
fundamentals of c
Pointer in C++
C++ tokens and expressions
Ad

Similar to Basic C Programming language (20)

PPTX
BCP_u2.pptxBCP_u2.pptxBCP_u2.pptxBCP_u2.pptx
PPT
Basics of C.ppt
PDF
C programming introduction for beginners.pdf
PPTX
CSE113 (UNIT-2)Storage classes in the computer science.pptx
PDF
C Programming - Refresher - Part I
PPTX
C_Programming_Language_tutorial__Autosaved_.pptx
PPT
Introduction to C
PDF
C programme presentation
DOC
C language
PPTX
Introduction to c programming
DOC
1. introduction to computer
PPTX
Shivani PPt C-programing-1.pptx
PDF
java or oops class not in kerala polytechnic 4rth semester nots j
PPT
Unit i intro-operators
PPTX
Chapter1.pptx
PPTX
Introduction to c
PPT
FINAL.ppt
PPT
Basics of C.ppt C PROGRAMMING AND DATA STRUCT
PPT
C program
PDF
C programming.pdf
BCP_u2.pptxBCP_u2.pptxBCP_u2.pptxBCP_u2.pptx
Basics of C.ppt
C programming introduction for beginners.pdf
CSE113 (UNIT-2)Storage classes in the computer science.pptx
C Programming - Refresher - Part I
C_Programming_Language_tutorial__Autosaved_.pptx
Introduction to C
C programme presentation
C language
Introduction to c programming
1. introduction to computer
Shivani PPt C-programing-1.pptx
java or oops class not in kerala polytechnic 4rth semester nots j
Unit i intro-operators
Chapter1.pptx
Introduction to c
FINAL.ppt
Basics of C.ppt C PROGRAMMING AND DATA STRUCT
C program
C programming.pdf
Ad

Recently uploaded (20)

PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Insiders guide to clinical Medicine.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
01-Introduction-to-Information-Management.pdf
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
RMMM.pdf make it easy to upload and study
PPTX
Institutional Correction lecture only . . .
PPTX
Cell Types and Its function , kingdom of life
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Pre independence Education in Inndia.pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Business Ethics Teaching Materials for college
PPTX
Pharma ospi slides which help in ospi learning
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
O7-L3 Supply Chain Operations - ICLT Program
TR - Agricultural Crops Production NC III.pdf
Supply Chain Operations Speaking Notes -ICLT Program
Insiders guide to clinical Medicine.pdf
Final Presentation General Medicine 03-08-2024.pptx
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
01-Introduction-to-Information-Management.pdf
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
RMMM.pdf make it easy to upload and study
Institutional Correction lecture only . . .
Cell Types and Its function , kingdom of life
Microbial disease of the cardiovascular and lymphatic systems
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Pre independence Education in Inndia.pdf
PPH.pptx obstetrics and gynecology in nursing
Module 4: Burden of Disease Tutorial Slides S2 2025
Business Ethics Teaching Materials for college
Pharma ospi slides which help in ospi learning
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Abdominal Access Techniques with Prof. Dr. R K Mishra

Basic C Programming language

  • 2. Overview § Computer System § Architecture of Computer System § Need of C Programming Language § History of C § Tokens in C
  • 3. Computer System § Is a collection of related Components that have all been design to work together Smoothly § Bits and Byte § Use of Computer
  • 6. Communication between User and Machine User want to interact with machine but machine only knows language in the form of 0’s and 1’s i.e. Bit (Binary Language) User Machine • So Binary language is also known as Machine level language but it is difficult to understand because it is in the form of bits. • So user want language that is close to user and we know it as High level language . • High level language is just like English language, all instructions are in friendly approach.
  • 7. Need of Translator • Computer only understands Binary language and user only understands High level language. • So there are two types of translators 1)Compiler 2)Interpreter
  • 8. Difference between Compiler and Interpreter Compiler Interpreter Compiler Takes Entire program as input Interpreter Takes Single instruction as input . Intermediate Object Code is Generated No Intermediate Object Code is Generated Conditional Control Statements are Executes faster Conditional Control Statements are Executes slower Memory Requirement : More (Since Object Code is Generated) Memory Requirement is Less Program need not be compiled every time Every time higher level program is converted into lower level program Errors are displayed after entire program is checked Errors are displayed for every instruction interpreted (if any) Example : C Compiler Example : BASIC 8
  • 9. History of programming language low-level languages:- • Those are machine languages and machine- dependent. • Fully binary, and symbolic so not code efficient. • Such languages are- §Fortran §Algol 60 §Cobol §Basic §Simula 67 §Pascal
  • 10. Need of C Language C is called as Middle level language. § Behaves as High Level Language through Functions - gives a modular programming § It gives access to the low level memory through Pointers § As its a combination of these two aspects, its neither a High Level nor a Low level language ,so C is Middle Level Language.
  • 11. History of C Language • Developed at Bell Laboratories in 1972 by Dennis Ritchie. • Features were derived from earlier language called “B” (Basic Combined Programming Language – BCPL)which is developed by Ken Thompson in 1970’s. • Invented for implementing UNIX operating system
  • 12. C Programming Basics Each language is made up of two parts, § Vocabulary § Grammar In programming language, § Vocabulary means Tokens § Grammar means Syntax
  • 13. C Tokens – Basic buildings blocks which are constructed together to write a C program. – Identifiers – Variables – Constants – Character Set – Keywords – Data types – Operators
  • 14. Identifier • Unique name given to identify units • E.g.int Num Num is identifier given to integer variable
  • 15. Variable • Name given to the location in a memory which is used to hold the value. • The value of the C variable may get change in the program. • C variable can hold values like integer, float point, character etc. • E.g. Age, height etc.
  • 16. Constant • Name given to the location in a memory which is used to hold the value . • Values can not be modified by the program once they are defined. • Constant might be belonging to any type like integer, float point, character etc. • E.g. Pi value=3.14
  • 17. Character set C language have collection of different character set which contain Alphabets A-Z, a-z Digits 0-9 Special symbols !,@,#,$,%,^,&,*,(,),_,+,=,-
  • 18. Keywords • Keywords are pre-defined words in a C compiler. • Also known as Reserved words. • Each keyword is meant to perform a specific function in a C program. • Since keywords are referred names for compiler, they can’t be used as variable name. • C language have 32 keywords.
  • 22. Declaration of Variable Syntax- Data_type variable_name; • Integer data types: § Keyword int is used for declaring the variable with integer type. § For example: int var1; • Floating data types: § Variables of floating types can hold real values(numbers). § Keywords either float or double is used for declaring floating type variable. § For example: float var2; • Character types: § Keyword char is used for declaring the variable of character type. § For example: char var4='h';
  • 23. Operators in C • Symbol that tells the compiler to perform specific mathematical or logical operations. • Types of operators- § Arithmetic Operators § Relational Operators § Increment Operator § Decrement Operator § Logical Operators § Conditional Operator
  • 24. Arithmetic Operators • Used to perform arithmetic operations. Operator Description Example(A=10,B=20) + Adds two operands A + B will give 30 - Subtracts second operand from the first A - B will give -10 * Multiplies both operands A * B will give 200 / Divides numerator by de-numerator B / A will give 2 % Modulus Operator and remainder of after an integer division B % A will give 0
  • 25. Relational Operators Operator Description Example(A=10,B=20) == Checks two operands are equal or not, if yes then condition becomes true. (A == B) is not true. != Checks two operands are equal or not, if values are not equal then condition becomes true. (A != B) is true. > Checks left operand is greater than right operand, if yes then condition becomes true. (A > B) is not true. < Checks left operand is less than right operand, if yes then condition becomes true. (A < B) is true. >= Checks left operand is greater than or equal to the right operand, if yes then condition becomes true. (A >= B) is not true. <= Checks left operand is less than or equal to right operand, if yes then condition becomes true. (A <= B) is true.
  • 26. Logical Operators • They evaluate each operation result in terms of 0 and 1. • Logical Operators are three type as – AND- (&&) – OR-(||) – NOT-(!)
  • 27. Increment Operator(++) • Increment operator increase the value of subsequent by 1. value may be increase according to the programmer. • Increment operator are two types as follows : – Post increment – Pre increment Post increment Pre increment A=10 B=A++ A=11 A=10 B=++A A=11 B=10 B=11
  • 28. Decrement Operator(--) • Decrement operators decrease the value to one, two and so on. • Two type as, – Post decrement – Pre decrement Post Decrement Pre Decrement A=10 B=A-- A=9 A=10 B=--A A=9 B=10 B=9
  • 29. Conditional Operator(?:) • Ternary operator • Syntax: condition ? result1 : result2 • If the condition is true, result1 is returned else result2 is returned.
  • 30. Largest no among 3 no's using conditional Operator      Max=(A>B) ? ((A>C)?A:C) : ((B>C)?B:C) 

Editor's Notes

  • #2: Summarize presentation content by restating the important points from the lessons. What do you want the audience to remember when they leave your presentation? Save your presentation to a video for easy distribution (To create a video, click the File tab, and then click Share.  Under File Types, click Create a Video.) &amp;lt;number&amp;gt; 3/7/16
  • #3: Summarize presentation content by restating the important points from the lessons. What do you want the audience to remember when they leave your presentation? Save your presentation to a video for easy distribution (To create a video, click the File tab, and then click Share.  Under File Types, click Create a Video.) &amp;lt;number&amp;gt; 3/7/16
  • #4: Summarize presentation content by restating the important points from the lessons. What do you want the audience to remember when they leave your presentation? Save your presentation to a video for easy distribution (To create a video, click the File tab, and then click Share.  Under File Types, click Create a Video.) &amp;lt;number&amp;gt; 3/7/16
  • #5: Summarize presentation content by restating the important points from the lessons. What do you want the audience to remember when they leave your presentation? Save your presentation to a video for easy distribution (To create a video, click the File tab, and then click Share.  Under File Types, click Create a Video.) &amp;lt;number&amp;gt; 3/7/16
  • #6: Summarize presentation content by restating the important points from the lessons. What do you want the audience to remember when they leave your presentation? Save your presentation to a video for easy distribution (To create a video, click the File tab, and then click Share.  Under File Types, click Create a Video.) &amp;lt;number&amp;gt; 3/7/16