SlideShare uma empresa Scribd logo
1 de 36
Introduction to C
Programming
Introduction
Books
 “The Waite Group’s Turbo C Programming
for PC”, Robert Lafore, SAMS
 Teach Yourself C : Herbert Schildt
 Programming in ANSI C- E. Balagurusamy
What is C?
 C
 A language written by Brian Kernighan
and Dennis Ritchie. This was to be the
language that UNIX was written in to
become the first "portable" language.
In recent years C has been used as a general-
purpose language because of its popularity with
programmers.
Why use C?
 Mainly because it produces code that runs nearly as fast
as code written in assembly language. Some examples
of the use of C might be:
– Operating Systems
– Language Compilers
– Assemblers
– Text Editors
– Print Spoolers
– Network Drivers
– Modern Programs
– Data Bases
– Language Interpreters
– Utilities
Mainly because of the portability that writing standard C programs can
offer
History
 In 1972 Dennis Ritchie at Bell Labs writes C and in
1978 the publication of The C Programming Language
by Kernighan & Ritchie caused a revolution in the
computing world
 In 1983, the American National Standards Institute
(ANSI) established a committee to provide a modern,
comprehensive definition of C. The resulting definition,
the ANSI standard, or "ANSI C", was completed late
1988.
Why C Still Useful?
 C provides:
 Efficiency, high performance and high quality
 flexibility and power
 many high-level and low-level operations  middle level
 Stability and small size code
 Provide functionality through rich set of function libraries
 Gateway for other professional languages like C  C++  Java
 C is used:
 System software Compilers, Editors, embedded systems
 data compression, graphics and computational geometry, utility
programs
 databases, operating systems, device drivers, system level
routines
 there are zillions of lines of C legacy code
 Also used in application programs
Software Development Method
 Requirement Specification
– Problem Definition
 Analysis
– Refine, Generalize, Decompose the problem definition
 Design
– Develop Algorithm
 Implementation
– Write Code
 Verification and Testing
– Test and Debug the code
Development with C
 Four stages
 Editing: Writing the source code by using some IDE or
editor
 Preprocessing or libraries: Already available routines
 compiling: translates or converts source to object code
for a specific platform source code -> object code
 linking: resolves external references and produces
the executable module
 Portable programs will run on any machine but…..
 Note! Program correctness and robustness are most
important than program efficiency
Programming languages
 Various programming languages
 Some understandable directly by computers
 Others require “translation” steps
– Machine language
• Natural language of a particular computer
• Consists of strings of numbers(1s, 0s)
• Instruct computer to perform elementary
operations one at a time
• Machine dependant
Programming languages
 Assembly Language
– English like abbreviations
– Translators programs called “Assemblers” to convert
assembly language programs to machine language.
– E.g. add overtime to base pay and store result in gross
pay
LOAD BASEPAY
ADD OVERPAY
STORE GROSSPAY
Programming languages
 High-level languages
– To speed up programming even further
– Single statements for accomplishing substantial tasks
– Translator programs called “Compilers” to convert
high-level programs into machine language
– E.g. add overtime to base pay and store result in
gross pay
grossPay = basePay + overtimePay
History of C
 Evolved from two previous languages
– BCPL , B
 BCPL (Basic Combined Programming Language) used
for writing OS & compilers
 B used for creating early versions of UNIX OS
 Both were “typeless” languages
 C language evolved from B (Dennis Ritchie – Bell labs)
** Typeless – no datatypes. Every data item occupied 1 word in memory.
History of C
 Hardware independent
 Programs portable to most computers
 Dialects of C
– Common C
– ANSI C
• ANSI/ ISO 9899: 1990
• Called American National Standards Institute
ANSI C
 Case-sensitive
C Standard Library
 Two parts to learning the “C” world
– Learn C itself
– Take advantage of rich collection of existing functions
called C Standard Library
 Avoid reinventing the wheel
Basics of C Environment
 C systems consist of 3 parts
– Environment
– Language
– C Standard Library
 Development environment has 6 phases
– Edit
– Pre-processor
– Compile
– Link
– Load
– Execute
Basics of C Environment
Editor DiskPhase 1
Program edited in
Editor and stored
on disk
Preprocessor DiskPhase 2
Preprocessor
program processes
the code
Compiler DiskPhase 3
Creates object code
and stores on disk
Linker DiskPhase 4
Links object code
with libraries and
stores on disk
Basics of C Environment
LoaderPhase 5
Puts program in
memory
Primary memory
CPUPhase 6
Takes each instruction
and executes it storing
new data values
Primary memory
Simple C Program
/* A first C Program*/
#include <stdio.h>
void main()
{
printf("Hello World n");
}
Simple C Program
 Line 1: #include <stdio.h>
 As part of compilation, the C compiler runs a program
called the C preprocessor. The preprocessor is able to
add and remove code from your source file.
 In this case, the directive #include tells the
preprocessor to include code from the file stdio.h.
 This file contains declarations for functions that the
program needs to use. A declaration for the printf
function is in this file.
Simple C Program
 Line 2: void main()
 This statement declares the main function.
 A C program can contain many functions but must
always have one main function.
 A function is a self-contained module of code that can
accomplish some task.
 Functions are examined later.
 The "void" specifies the return type of main. In this case,
nothing is returned to the operating system.
Simple C Program
 Line 3: {
 This opening bracket denotes the start of the program.
Simple C Program
 Line 4: printf("Hello World From Aboutn");
 Printf is a function from a standard C library that is used
to print strings to the standard output, normally your
screen.
 The compiler links code from these standard libraries to
the code you have written to produce the final
executable.
 The "n" is a special format modifier that tells the printf
to put a line feed at the end of the line.
 If there were another printf in this program, its string
would print on the next line.
Simple C Program
 Line 5: }
 This closing bracket denotes the end of the program.
Escape Sequence
 n new line
 t tab
 r carriage return
 a alert
  backslash
 ” double quote
Memory concepts
 Every variable has a name, type and value
 Variable names correspond to locations in computer
memory
 New value over-writes the previous value– “Destructive
read-in”
 Value reading called “Non-destructive read-out”
Arithmetic in C
C operation Algebraic C
Addition(+) f+7 f+7
Subtraction (-) p-c p-c
Multiplication(*) bm b*m
Division(/) x/y, x , x y x/y
Modulus(%) r mod s r%s
Precedence order
 Highest to lowest
• ()
• *, /, %
• +, -
Example
Algebra:
z = pr%q+w/x-y
C:
z = p * r % q + w / x – y ;
Precedence:
1 2 4 3 5
Example
Algebra:
a(b+c)+ c(d+e)
C:
a * ( b + c ) + c * ( d + e ) ;
Precedence:
3 1 5 4 2
Decision Making
 Checking falsity or truth of a statement
 Equality operators have lower precedence than
relational operators
 Relational operators have same precedence
 Both associate from left to right
Decision Making
 Equality operators
• ==
• !=
 Relational operators
• <
• >
• <=
• >=
Summary of precedence order
Operator Associativity
() left to right
* / % left to right
+ - left to right
< <= > >= left to right
== != left to right
= left to right
Assignment operators
 =
 +=
 -=
 *=
 /=
 %=
Increment/ decrement operators
 ++ ++a
 ++ a++
 -- --a
 -- a--
Increment/ decrement operators
main()
{
int c;
c = 5;
printf(“%dn”, c);
printf(“%dn”, c++);
printf(“%dnn”, c);
c = 5;
printf(“%dn”, c);
printf(“%dn”, ++c);
printf(“%dn”, c);
return 0;
}
5
5
6
5
6
6
Thank You
 Thank You

Mais conteúdo relacionado

Mais procurados

Programming in C Presentation upto FILE
Programming in C Presentation upto FILEProgramming in C Presentation upto FILE
Programming in C Presentation upto FILEDipta Saha
 
PYTHON NOTES
PYTHON NOTESPYTHON NOTES
PYTHON NOTESNi
 
Conditional Statement in C Language
Conditional Statement in C LanguageConditional Statement in C Language
Conditional Statement in C LanguageShaina Arora
 
Notes of c programming 1st unit BCA I SEM
Notes of c programming  1st unit BCA I SEMNotes of c programming  1st unit BCA I SEM
Notes of c programming 1st unit BCA I SEMMansi Tyagi
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C ProgrammingShuvongkor Barman
 
Programming Fundamentals lecture 1
Programming Fundamentals lecture 1Programming Fundamentals lecture 1
Programming Fundamentals lecture 1REHAN IJAZ
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programmingprogramming9
 
Variables in C and C++ Language
Variables in C and C++ LanguageVariables in C and C++ Language
Variables in C and C++ LanguageWay2itech
 
Steps for c program execution
Steps for c program executionSteps for c program execution
Steps for c program executionRumman Ansari
 
Presentation on C++ Programming Language
Presentation on C++ Programming LanguagePresentation on C++ Programming Language
Presentation on C++ Programming Languagesatvirsandhu9
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c languagetanmaymodi4
 

Mais procurados (20)

Programming in C Presentation upto FILE
Programming in C Presentation upto FILEProgramming in C Presentation upto FILE
Programming in C Presentation upto FILE
 
C programming
C programmingC programming
C programming
 
Algorithm Introduction
Algorithm IntroductionAlgorithm Introduction
Algorithm Introduction
 
Preprocessor
PreprocessorPreprocessor
Preprocessor
 
PYTHON NOTES
PYTHON NOTESPYTHON NOTES
PYTHON NOTES
 
Conditional Statement in C Language
Conditional Statement in C LanguageConditional Statement in C Language
Conditional Statement in C Language
 
File handling in c
File handling in cFile handling in c
File handling in c
 
Function in C program
Function in C programFunction in C program
Function in C program
 
C presentation
C presentationC presentation
C presentation
 
Notes of c programming 1st unit BCA I SEM
Notes of c programming  1st unit BCA I SEMNotes of c programming  1st unit BCA I SEM
Notes of c programming 1st unit BCA I SEM
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C Programming
 
Programming Fundamentals lecture 1
Programming Fundamentals lecture 1Programming Fundamentals lecture 1
Programming Fundamentals lecture 1
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
Variables in C and C++ Language
Variables in C and C++ LanguageVariables in C and C++ Language
Variables in C and C++ Language
 
Functions in C
Functions in CFunctions in C
Functions in C
 
C Programming Unit-5
C Programming Unit-5C Programming Unit-5
C Programming Unit-5
 
C if else
C if elseC if else
C if else
 
Steps for c program execution
Steps for c program executionSteps for c program execution
Steps for c program execution
 
Presentation on C++ Programming Language
Presentation on C++ Programming LanguagePresentation on C++ Programming Language
Presentation on C++ Programming Language
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
 

Destaque

Destaque (12)

structured programming Introduction to c fundamentals
structured programming Introduction to c fundamentalsstructured programming Introduction to c fundamentals
structured programming Introduction to c fundamentals
 
Mickey mouse
Mickey mouseMickey mouse
Mickey mouse
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
Green chemistry
Green chemistryGreen chemistry
Green chemistry
 
Why C is Called Structured Programming Language
Why C is Called Structured Programming LanguageWhy C is Called Structured Programming Language
Why C is Called Structured Programming Language
 
Programmer ppt
Programmer pptProgrammer ppt
Programmer ppt
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
Biotechnology
BiotechnologyBiotechnology
Biotechnology
 
Biotech & medicine.ppt
Biotech & medicine.pptBiotech & medicine.ppt
Biotech & medicine.ppt
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
 
Solar panel Technology ppt
Solar panel Technology pptSolar panel Technology ppt
Solar panel Technology ppt
 
Solar energy ppt
Solar energy pptSolar energy ppt
Solar energy ppt
 

Semelhante a Introduction to C programming

What is turbo c and how it works
What is turbo c and how it worksWhat is turbo c and how it works
What is turbo c and how it worksMark John Lado, MIT
 
Basics of C Lecture 2[16097].pptx
Basics of C Lecture 2[16097].pptxBasics of C Lecture 2[16097].pptx
Basics of C Lecture 2[16097].pptxCoolGamer16
 
Introduction of c language
Introduction of c languageIntroduction of c language
Introduction of c languagefarishah
 
C Programming UNIT 1.pptx
C Programming  UNIT 1.pptxC Programming  UNIT 1.pptx
C Programming UNIT 1.pptxMugilvannan11
 
Bsc cs i pic u-1 introduction to c language
Bsc cs i pic u-1 introduction to c languageBsc cs i pic u-1 introduction to c language
Bsc cs i pic u-1 introduction to c languageRai University
 
introduction to c language
 introduction to c language introduction to c language
introduction to c languageRai University
 
Mca i pic u-1 introduction to c language
Mca i pic u-1 introduction to c languageMca i pic u-1 introduction to c language
Mca i pic u-1 introduction to c languageRai University
 
Btech i pic u-1 introduction to c language
Btech i pic u-1 introduction to c languageBtech i pic u-1 introduction to c language
Btech i pic u-1 introduction to c languageRai University
 
Diploma ii cfpc u-1 introduction to c language
Diploma ii  cfpc u-1 introduction to c languageDiploma ii  cfpc u-1 introduction to c language
Diploma ii cfpc u-1 introduction to c languageRai University
 
Chapter 1 Introduction to C .pptx
Chapter 1 Introduction to C .pptxChapter 1 Introduction to C .pptx
Chapter 1 Introduction to C .pptxAbdalla536859
 
C LANGUAGE UNIT-1 PREPARED BY MVB REDDY
C LANGUAGE UNIT-1 PREPARED BY MVB REDDYC LANGUAGE UNIT-1 PREPARED BY MVB REDDY
C LANGUAGE UNIT-1 PREPARED BY MVB REDDYRajeshkumar Reddy
 
Intro to cprogramming
Intro to cprogrammingIntro to cprogramming
Intro to cprogrammingskashwin98
 
C programming presentation(final)
C programming presentation(final)C programming presentation(final)
C programming presentation(final)aaravSingh41
 

Semelhante a Introduction to C programming (20)

C PROGRAMMING
C PROGRAMMINGC PROGRAMMING
C PROGRAMMING
 
C intro
C introC intro
C intro
 
01 c
01 c01 c
01 c
 
What is turbo c and how it works
What is turbo c and how it worksWhat is turbo c and how it works
What is turbo c and how it works
 
Basics of C Lecture 2[16097].pptx
Basics of C Lecture 2[16097].pptxBasics of C Lecture 2[16097].pptx
Basics of C Lecture 2[16097].pptx
 
Introduction of c language
Introduction of c languageIntroduction of c language
Introduction of c language
 
C Programming UNIT 1.pptx
C Programming  UNIT 1.pptxC Programming  UNIT 1.pptx
C Programming UNIT 1.pptx
 
Bsc cs i pic u-1 introduction to c language
Bsc cs i pic u-1 introduction to c languageBsc cs i pic u-1 introduction to c language
Bsc cs i pic u-1 introduction to c language
 
introduction to c language
 introduction to c language introduction to c language
introduction to c language
 
Mca i pic u-1 introduction to c language
Mca i pic u-1 introduction to c languageMca i pic u-1 introduction to c language
Mca i pic u-1 introduction to c language
 
Btech i pic u-1 introduction to c language
Btech i pic u-1 introduction to c languageBtech i pic u-1 introduction to c language
Btech i pic u-1 introduction to c language
 
Diploma ii cfpc u-1 introduction to c language
Diploma ii  cfpc u-1 introduction to c languageDiploma ii  cfpc u-1 introduction to c language
Diploma ii cfpc u-1 introduction to c language
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
Chapter 1 Introduction to C .pptx
Chapter 1 Introduction to C .pptxChapter 1 Introduction to C .pptx
Chapter 1 Introduction to C .pptx
 
C LANGUAGE UNIT-1 PREPARED BY MVB REDDY
C LANGUAGE UNIT-1 PREPARED BY MVB REDDYC LANGUAGE UNIT-1 PREPARED BY MVB REDDY
C LANGUAGE UNIT-1 PREPARED BY MVB REDDY
 
Intro to cprogramming
Intro to cprogrammingIntro to cprogramming
Intro to cprogramming
 
Csc240 -lecture_3
Csc240  -lecture_3Csc240  -lecture_3
Csc240 -lecture_3
 
Basic c
Basic cBasic c
Basic c
 
C tutorials
C tutorialsC tutorials
C tutorials
 
C programming presentation(final)
C programming presentation(final)C programming presentation(final)
C programming presentation(final)
 

Mais de Rokonuzzaman Rony (20)

Course outline for c programming
Course outline for c  programming Course outline for c  programming
Course outline for c programming
 
Pointer
PointerPointer
Pointer
 
Operator Overloading & Type Conversions
Operator Overloading & Type ConversionsOperator Overloading & Type Conversions
Operator Overloading & Type Conversions
 
Constructors & Destructors
Constructors  & DestructorsConstructors  & Destructors
Constructors & Destructors
 
Classes and objects in c++
Classes and objects in c++Classes and objects in c++
Classes and objects in c++
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 
Object Oriented Programming with C++
Object Oriented Programming with C++Object Oriented Programming with C++
Object Oriented Programming with C++
 
Humanitarian task and its importance
Humanitarian task and its importanceHumanitarian task and its importance
Humanitarian task and its importance
 
Structure
StructureStructure
Structure
 
Pointers
 Pointers Pointers
Pointers
 
Loops
LoopsLoops
Loops
 
Array
ArrayArray
Array
 
Constants, Variables, and Data Types
Constants, Variables, and Data TypesConstants, Variables, and Data Types
Constants, Variables, and Data Types
 
C Programming language
C Programming languageC Programming language
C Programming language
 
User defined functions
User defined functionsUser defined functions
User defined functions
 
Numerical Method 2
Numerical Method 2Numerical Method 2
Numerical Method 2
 
Numerical Method
Numerical Method Numerical Method
Numerical Method
 
Data structures
Data structuresData structures
Data structures
 
Data structures
Data structures Data structures
Data structures
 
Data structures
Data structures Data structures
Data structures
 

Último

Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxnelietumpap1
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 

Último (20)

Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 

Introduction to C programming

  • 2. Books  “The Waite Group’s Turbo C Programming for PC”, Robert Lafore, SAMS  Teach Yourself C : Herbert Schildt  Programming in ANSI C- E. Balagurusamy
  • 3. What is C?  C  A language written by Brian Kernighan and Dennis Ritchie. This was to be the language that UNIX was written in to become the first "portable" language. In recent years C has been used as a general- purpose language because of its popularity with programmers.
  • 4. Why use C?  Mainly because it produces code that runs nearly as fast as code written in assembly language. Some examples of the use of C might be: – Operating Systems – Language Compilers – Assemblers – Text Editors – Print Spoolers – Network Drivers – Modern Programs – Data Bases – Language Interpreters – Utilities Mainly because of the portability that writing standard C programs can offer
  • 5. History  In 1972 Dennis Ritchie at Bell Labs writes C and in 1978 the publication of The C Programming Language by Kernighan & Ritchie caused a revolution in the computing world  In 1983, the American National Standards Institute (ANSI) established a committee to provide a modern, comprehensive definition of C. The resulting definition, the ANSI standard, or "ANSI C", was completed late 1988.
  • 6. Why C Still Useful?  C provides:  Efficiency, high performance and high quality  flexibility and power  many high-level and low-level operations  middle level  Stability and small size code  Provide functionality through rich set of function libraries  Gateway for other professional languages like C  C++  Java  C is used:  System software Compilers, Editors, embedded systems  data compression, graphics and computational geometry, utility programs  databases, operating systems, device drivers, system level routines  there are zillions of lines of C legacy code  Also used in application programs
  • 7. Software Development Method  Requirement Specification – Problem Definition  Analysis – Refine, Generalize, Decompose the problem definition  Design – Develop Algorithm  Implementation – Write Code  Verification and Testing – Test and Debug the code
  • 8. Development with C  Four stages  Editing: Writing the source code by using some IDE or editor  Preprocessing or libraries: Already available routines  compiling: translates or converts source to object code for a specific platform source code -> object code  linking: resolves external references and produces the executable module  Portable programs will run on any machine but…..  Note! Program correctness and robustness are most important than program efficiency
  • 9. Programming languages  Various programming languages  Some understandable directly by computers  Others require “translation” steps – Machine language • Natural language of a particular computer • Consists of strings of numbers(1s, 0s) • Instruct computer to perform elementary operations one at a time • Machine dependant
  • 10. Programming languages  Assembly Language – English like abbreviations – Translators programs called “Assemblers” to convert assembly language programs to machine language. – E.g. add overtime to base pay and store result in gross pay LOAD BASEPAY ADD OVERPAY STORE GROSSPAY
  • 11. Programming languages  High-level languages – To speed up programming even further – Single statements for accomplishing substantial tasks – Translator programs called “Compilers” to convert high-level programs into machine language – E.g. add overtime to base pay and store result in gross pay grossPay = basePay + overtimePay
  • 12. History of C  Evolved from two previous languages – BCPL , B  BCPL (Basic Combined Programming Language) used for writing OS & compilers  B used for creating early versions of UNIX OS  Both were “typeless” languages  C language evolved from B (Dennis Ritchie – Bell labs) ** Typeless – no datatypes. Every data item occupied 1 word in memory.
  • 13. History of C  Hardware independent  Programs portable to most computers  Dialects of C – Common C – ANSI C • ANSI/ ISO 9899: 1990 • Called American National Standards Institute ANSI C  Case-sensitive
  • 14. C Standard Library  Two parts to learning the “C” world – Learn C itself – Take advantage of rich collection of existing functions called C Standard Library  Avoid reinventing the wheel
  • 15. Basics of C Environment  C systems consist of 3 parts – Environment – Language – C Standard Library  Development environment has 6 phases – Edit – Pre-processor – Compile – Link – Load – Execute
  • 16. Basics of C Environment Editor DiskPhase 1 Program edited in Editor and stored on disk Preprocessor DiskPhase 2 Preprocessor program processes the code Compiler DiskPhase 3 Creates object code and stores on disk Linker DiskPhase 4 Links object code with libraries and stores on disk
  • 17. Basics of C Environment LoaderPhase 5 Puts program in memory Primary memory CPUPhase 6 Takes each instruction and executes it storing new data values Primary memory
  • 18. Simple C Program /* A first C Program*/ #include <stdio.h> void main() { printf("Hello World n"); }
  • 19. Simple C Program  Line 1: #include <stdio.h>  As part of compilation, the C compiler runs a program called the C preprocessor. The preprocessor is able to add and remove code from your source file.  In this case, the directive #include tells the preprocessor to include code from the file stdio.h.  This file contains declarations for functions that the program needs to use. A declaration for the printf function is in this file.
  • 20. Simple C Program  Line 2: void main()  This statement declares the main function.  A C program can contain many functions but must always have one main function.  A function is a self-contained module of code that can accomplish some task.  Functions are examined later.  The "void" specifies the return type of main. In this case, nothing is returned to the operating system.
  • 21. Simple C Program  Line 3: {  This opening bracket denotes the start of the program.
  • 22. Simple C Program  Line 4: printf("Hello World From Aboutn");  Printf is a function from a standard C library that is used to print strings to the standard output, normally your screen.  The compiler links code from these standard libraries to the code you have written to produce the final executable.  The "n" is a special format modifier that tells the printf to put a line feed at the end of the line.  If there were another printf in this program, its string would print on the next line.
  • 23. Simple C Program  Line 5: }  This closing bracket denotes the end of the program.
  • 24. Escape Sequence  n new line  t tab  r carriage return  a alert  backslash  ” double quote
  • 25. Memory concepts  Every variable has a name, type and value  Variable names correspond to locations in computer memory  New value over-writes the previous value– “Destructive read-in”  Value reading called “Non-destructive read-out”
  • 26. Arithmetic in C C operation Algebraic C Addition(+) f+7 f+7 Subtraction (-) p-c p-c Multiplication(*) bm b*m Division(/) x/y, x , x y x/y Modulus(%) r mod s r%s
  • 27. Precedence order  Highest to lowest • () • *, /, % • +, -
  • 28. Example Algebra: z = pr%q+w/x-y C: z = p * r % q + w / x – y ; Precedence: 1 2 4 3 5
  • 29. Example Algebra: a(b+c)+ c(d+e) C: a * ( b + c ) + c * ( d + e ) ; Precedence: 3 1 5 4 2
  • 30. Decision Making  Checking falsity or truth of a statement  Equality operators have lower precedence than relational operators  Relational operators have same precedence  Both associate from left to right
  • 31. Decision Making  Equality operators • == • !=  Relational operators • < • > • <= • >=
  • 32. Summary of precedence order Operator Associativity () left to right * / % left to right + - left to right < <= > >= left to right == != left to right = left to right
  • 33. Assignment operators  =  +=  -=  *=  /=  %=
  • 34. Increment/ decrement operators  ++ ++a  ++ a++  -- --a  -- a--
  • 35. Increment/ decrement operators main() { int c; c = 5; printf(“%dn”, c); printf(“%dn”, c++); printf(“%dnn”, c); c = 5; printf(“%dn”, c); printf(“%dn”, ++c); printf(“%dn”, c); return 0; } 5 5 6 5 6 6