SlideShare a Scribd company logo
Unit - 2
Mithun D’Souza
Assistant Professor,
Department of Computer Science,
PES Institute of Advanced Management Studies,
Shivamogga
 C is a general-purpose, high-level language that was originally
developed by Dennis M. Ritchie to develop the UNIX operating
system at Bell Labs.
 C was originally first implemented on the DEC PDP-11 computer in
1972.
 In 1978, Brian Kernighan and Dennis Ritchie produced the first
publicly available description of C, now known as the K&R standard.
 The UNIX operating system, the C compiler, and essentially all
UNIX application programs have been written in C.
 In 1988, the American National Standards Institute (ANSI) had
formalized the C language.
 C was invented to write UNIX operating system.
 C is a successor of 'Basic Combined Programming Language' (BCPL)
called B language.
 Linux OS, PHP, and MySQL are written in C.
 C has been written in assembly language
Unit 2   introduction to c programming
 C has now become a widely used professional language for
various reasons:
 Easy to learn
 Structured language
 It produces efficient programs
 It can handle low-level activities
 It can be compiled on a variety of computer platforms
 C was invented to write an operating system called UNIX.
 C is a successor of B language which was introduced around the early
1970s.
 The language was formalized in 1988 by the American National
Standard Institute (ANSI).
 The UNIX OS was totally written in C.
 Today C is the most widely used and popular System Programming
Language.
 Most of the state-of-the-art software have been implemented using C.
 Today's most popular Linux OS and RDBMS MySQL have been
written in C.
 C was initially used for system development work, particularly the
programs that make-up the operating system.
 C was adopted as a system development language because it produces
code that runs nearly as fast as the code written in assembly language.
 Operating Systems
 Language Compilers
 Assemblers
 Text Editors
 Print Spoolers
 Network Drivers
 Modern Programs
 Databases
 Language Interpreters
 Utilities
Unit 2   introduction to c programming
 In C, compiler is a special tool that compiles the program and
converts it into the object file which is machine readable.
 After the compilation process, the linker will combine different object
files and creates a single executable file to run the program.
 General purpose Programming Language
 Structured Programming Language
 Helps in the development of System Software
 Rich set of Operators
 Provides compact representation for expressions
 Allows manipulation of internal processor registers
 No rigid format: Any Number of statement can be typed in a single line
 Portability: any C program can be run on different machines with little or no
modification
 Supports a rich set of data types
 Very less number of reserved words
 Pointer arithmetic and pointer manipulation
 Ability to extend itself by adding functions to its library
Unit 2   introduction to c programming
 System Software
 Operating systems
 Compilers
 Assemblers
 Editors
 Loaders
 Linkers
 Application Software
 Database Management Systems (DBMS)
 Graphics Packages
 Spread sheets
 CAD/CAM applications
 Word Processors
 Office Automation Tools
 Scientific and Engineering applications
1) Comment line
2) Preprocessor directive
3) Global variable declaration
4) main function( )
{
Local variables;
Statements;
}
User defined function ( )
{
// user defined instructions/ statements
}
Unit 2   introduction to c programming
 It indicates the purpose of the program. It is represented as
/*……………………………..*/
 Comment line is used for increasing the readability of the program.
 It is useful in explaining the program and generally used for
documentation.
 It is enclosed within the decimeters.
 Comment line can be single or multiple line but should not be
nested.
 It can be anywhere in the program except inside string constant &
character constant.
 #include<stdio.h> tells the compiler to include information about the
standard input/output library.
 It is also used in symbolic constant such as #define PI 3.14(value).
 The stdio.h (standard input output header file)
 contains definition &declaration of system defined function such as
 printf( ) - Printing on screen
 scanf( ) - Reading data from user
 pow( ) etc.
 Generally printf() function used to display and scanf() function used
to read value
Unit 2   introduction to c programming
 This is the section where variable are declared globally
 It can be access by all the functions used in the program.
 And it is generally declared outside the function
 It is the user defined function and every function has one main()
function from where actually program is started and it is encloses
within the pair of curly braces.
 The main( ) function can be anywhere in the program but in general
practice it is placed in the first position.
Syntax :
main()
{
……..
……..
……..
}
 The main( ) function return value when it declared by data type as
int main( )
{
return 0
}
 The main function does not return any value when void (means
null/empty) as
void main(void ) or void main()
{
printf (“C language”);
}
Output: C language
 The program execution start with opening braces and end with closing
brace.
 And in between the two braces declaration part as well as executable part is
mentioned.
 And at the end of each line, the semi-colon is given which indicates
statement termination.
/*First c program with return statement*/
#include <stdio.h>
int main (void)
{
printf ("welcome to c Programming language.n");
return 0;
}
Output: welcome to c programming language.
 A compiler is a software program that analyzes a program developed
in a particular computer language and then translates it into a form
that is suitable for execution on a particular computer system.
 The steps involves
 entering,
 compiling, and
 executing a computer program
 Which are developed in the C programming language
 The typical Unix commands that would be entered from the command
line
Unit 2   introduction to c programming
#include <stdio.h>
int main (void)
{
int v1, v2, sum;
//v1,v2,sum are variables and int is data type declared
v1 = 150;
v2 = 25;
sum = v1 + v2;
printf ("The sum of %i and %i is= %in", v1, v2, sum);
return 0;
}
Output: The sum of 150 and 25 is=175
 Every programming language has its own character set to form the
lexical elements.
 C Language Character Sets are:
 Alphabets
 Digits
 Special Characters
Unit 2   introduction to c programming
 The basic and smallest units of C program are called
C tokens.
 Keywords
 Identifiers
 Constants
 Strings
 Operators
 Special Symbols
 There are certain words reserved for doing specific task, these words
are known as reserved word or keywords.
 These words are predefined and always written in lower case or
small letter.
 These keywords can’t be used as a variable name as it assigned with
fixed meaning.
Example
 Identifiers are user defined word used to name of entities like
variables, arrays, functions, structures etc.
 Rules for naming identifiers are:
1) name should only consists of alphabets (both upper and lower case), digits
and underscore (_) sign.
2) first characters should be alphabet or underscore
3) name should not be a keyword
4) since C is a case sensitive, the upper case and lower case considered
differently, for example code, Code, CODE etc. are different identifiers.
5) identifiers are generally given in some meaningful name such as value,
net_salary, age, data etc.
 Constant is a any value that cannot be changed during program
execution.
 In C, any number, single character, or character string is known as a
constant.
 A constant is an entity that doesn’t change whereas a variable is an
entity that may change.
For example,
 Number 50 represents a constant integer value.
 The character string "Programming in C is fun.n" is an example of a constant
character string.
 C constants can be divided into two major categories:
 Primary Constants
 Secondary Constants
Unit 2   introduction to c programming
 Numeric constant
 Numeric constant consists of digits. It required minimum size of 2 bytes and max 4
bytes.
▪ Integer Constant
▪ Real Constant
 Character constant
 Character constant represented as a single character enclosed within a single quote.
 These can be single digit, single special symbol or white spaces such as ‘9’,’c’,’$’, ‘ ’
etc.
 String constant
 Set of characters are called string and when sequence of characters are enclosed
within a double quote.
 Some examples are “sarathina” , “908”, “3”,” ”, “A” etc.
 Symbolic constant
 Symbolic constant is a name that substitute for a sequence of characters and,
characters may be numeric, character or string constant.
 #define name value, #define MAX 10, #define CH ‘b’, #define NAME “sony”
 Variable is a data name which is used to store some data value or
symbolic names for storing program computations and results.
 The value of the variable can be changed during the execution.
 The rule for naming the variables is same as the naming identifier.
 Before used in the program it must be declared.
 Declaration of variables specify its name, data types and range of the
value that variables can store depends upon its data types.
Syntax:
int a;
char c;
float f;
 When we assign any initial value to variable during the declaration, is
called initialization of variables.
 When variable is declared but contain undefined value then it is
called garbage value.
 The variable is initialized with the assignment operator such as
Data type variable name = constant;
Example:
int a=20;
or
int a;
a=20;
 Data types refer to an extensive system used for declaring variables or
functions of different types before its use.
 The type of a variable determines how much space it occupies in
storage and how the bit pattern stored is interpreted.
 The value of a variable can be changed any time.
 C has the following 4 types of data types
 basic built-in data types: int, float, double, char
 Enumeration data type: enum
 Derived data type: pointer, array, structure, union
 Void data type: void
 A variable declared to be of type int can be used to contain integral
values only
 That is, values that do not contain decimal places.
 A variable declared to be of type float can be used for storing
floating- point numbers (values containing decimal places).
 The double type is the same as type float, only with roughly twice the
precision.
 The char data type can be used to store a single character, such as the
letter a, the digit character 6, or a semicolon similarly
 A variable declared char can only store character type value.
 There are two types of type qualifier in c
 Size qualifier: short, long
 Sign qualifier: signed, unsigned
 When the qualifier unsigned is used the number is always positive,
and when signed is used number may be positive or negative.
 If the sign qualifier is not mentioned, then by default sign qualifier is assumed.
 The range of values for signed data types is less than that of unsigned
data type.
 Because in signed type, the left most bit is used to represent sign,
while in unsigned type this bit is also used to represent the value.
Unit 2   introduction to c programming
C O M P L E T E D
Ad

More Related Content

What's hot (20)

Character Arrays and strings in c language
Character Arrays and strings in c languageCharacter Arrays and strings in c language
Character Arrays and strings in c language
mallikavin
 
c-programming
c-programmingc-programming
c-programming
Zulhazmi Harith
 
System Programming Overview
System Programming OverviewSystem Programming Overview
System Programming Overview
Dattatray Gandhmal
 
Data Type in C Programming
Data Type in C ProgrammingData Type in C Programming
Data Type in C Programming
Qazi Shahzad Ali
 
Data types in C
Data types in CData types in C
Data types in C
Tarun Sharma
 
Decision making and looping - c programming by YEASIN NEWAJ
Decision making and looping -  c programming by YEASIN NEWAJDecision making and looping -  c programming by YEASIN NEWAJ
Decision making and looping - c programming by YEASIN NEWAJ
YeasinNewaj
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
programming9
 
Increment and Decrement operators in C++
Increment and Decrement operators in C++Increment and Decrement operators in C++
Increment and Decrement operators in C++
Neeru Mittal
 
Function in C program
Function in C programFunction in C program
Function in C program
Nurul Zakiah Zamri Tan
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial
javaTpoint s
 
Decision making and looping
Decision making and loopingDecision making and looping
Decision making and looping
Hossain Md Shakhawat
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programming
TejaswiB4
 
Loops in c
Loops in cLoops in c
Loops in c
baabtra.com - No. 1 supplier of quality freshers
 
C LANGUAGE NOTES
C LANGUAGE NOTESC LANGUAGE NOTES
C LANGUAGE NOTES
Malikireddy Bramhananda Reddy
 
Lecture 5 - Structured Programming Language
Lecture 5 - Structured Programming Language Lecture 5 - Structured Programming Language
Lecture 5 - Structured Programming Language
Md. Imran Hossain Showrov
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
Manoj Tyagi
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
Vineeta Garg
 
C programming
C programmingC programming
C programming
Envision Computer Training Institute
 
Bitwise Operators in C
Bitwise Operators in CBitwise Operators in C
Bitwise Operators in C
yndaravind
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
Ahmad Idrees
 

Similar to Unit 2 introduction to c programming (20)

Introduction to C Unit 1
Introduction to C Unit 1Introduction to C Unit 1
Introduction to C Unit 1
Dr. SURBHI SAROHA
 
C programming language tutorial for beginers.pdf
C programming language tutorial for beginers.pdfC programming language tutorial for beginers.pdf
C programming language tutorial for beginers.pdf
ComedyTechnology
 
C Programming Unit-1
C Programming Unit-1C Programming Unit-1
C Programming Unit-1
Vikram Nandini
 
UNIT 5 C PROGRAMMING, PROGRAM STRUCTURE
UNIT 5  C PROGRAMMING, PROGRAM STRUCTUREUNIT 5  C PROGRAMMING, PROGRAM STRUCTURE
UNIT 5 C PROGRAMMING, PROGRAM STRUCTURE
MUHUMUZAONAN1
 
C programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer CentreC programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer Centre
jatin batra
 
C notes
C notesC notes
C notes
Raunak Sodhi
 
IIM.Com-FIT-Unit2(14.9.2021 TO 30.9.2021).pptx
IIM.Com-FIT-Unit2(14.9.2021 TO 30.9.2021).pptxIIM.Com-FIT-Unit2(14.9.2021 TO 30.9.2021).pptx
IIM.Com-FIT-Unit2(14.9.2021 TO 30.9.2021).pptx
rajkumar490591
 
C Lang notes.ppt
C Lang notes.pptC Lang notes.ppt
C Lang notes.ppt
ShivanadhuniBhanuPra
 
C programming language Reference Note
C programming language Reference NoteC programming language Reference Note
C programming language Reference Note
Chetan Thapa Magar
 
Chapter3
Chapter3Chapter3
Chapter3
Kamran
 
C Programming UNIT 1.pptx
C Programming  UNIT 1.pptxC Programming  UNIT 1.pptx
C Programming UNIT 1.pptx
Mugilvannan11
 
C basics 4 std11(GujBoard)
C basics 4 std11(GujBoard)C basics 4 std11(GujBoard)
C basics 4 std11(GujBoard)
indrasir
 
C programming introduction for beginners.pdf
C programming introduction for beginners.pdfC programming introduction for beginners.pdf
C programming introduction for beginners.pdf
sagarduari1
 
C language ppt
C language pptC language ppt
C language ppt
Ğäùråv Júñêjå
 
history of c.ppt
history of c.ppthistory of c.ppt
history of c.ppt
arpanabharani
 
1. introduction to computer
1. introduction to computer1. introduction to computer
1. introduction to computer
Shankar Gangaju
 
C programming course material
C programming course materialC programming course material
C programming course material
Ranjitha Murthy
 
490450755-Chapter-2.ppt
490450755-Chapter-2.ppt490450755-Chapter-2.ppt
490450755-Chapter-2.ppt
ManiMala75
 
490450755-Chapter-2.ppt
490450755-Chapter-2.ppt490450755-Chapter-2.ppt
490450755-Chapter-2.ppt
ManiMala75
 
C programming presentation(final)
C programming presentation(final)C programming presentation(final)
C programming presentation(final)
aaravSingh41
 
C programming language tutorial for beginers.pdf
C programming language tutorial for beginers.pdfC programming language tutorial for beginers.pdf
C programming language tutorial for beginers.pdf
ComedyTechnology
 
UNIT 5 C PROGRAMMING, PROGRAM STRUCTURE
UNIT 5  C PROGRAMMING, PROGRAM STRUCTUREUNIT 5  C PROGRAMMING, PROGRAM STRUCTURE
UNIT 5 C PROGRAMMING, PROGRAM STRUCTURE
MUHUMUZAONAN1
 
C programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer CentreC programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer Centre
jatin batra
 
IIM.Com-FIT-Unit2(14.9.2021 TO 30.9.2021).pptx
IIM.Com-FIT-Unit2(14.9.2021 TO 30.9.2021).pptxIIM.Com-FIT-Unit2(14.9.2021 TO 30.9.2021).pptx
IIM.Com-FIT-Unit2(14.9.2021 TO 30.9.2021).pptx
rajkumar490591
 
C programming language Reference Note
C programming language Reference NoteC programming language Reference Note
C programming language Reference Note
Chetan Thapa Magar
 
Chapter3
Chapter3Chapter3
Chapter3
Kamran
 
C Programming UNIT 1.pptx
C Programming  UNIT 1.pptxC Programming  UNIT 1.pptx
C Programming UNIT 1.pptx
Mugilvannan11
 
C basics 4 std11(GujBoard)
C basics 4 std11(GujBoard)C basics 4 std11(GujBoard)
C basics 4 std11(GujBoard)
indrasir
 
C programming introduction for beginners.pdf
C programming introduction for beginners.pdfC programming introduction for beginners.pdf
C programming introduction for beginners.pdf
sagarduari1
 
1. introduction to computer
1. introduction to computer1. introduction to computer
1. introduction to computer
Shankar Gangaju
 
C programming course material
C programming course materialC programming course material
C programming course material
Ranjitha Murthy
 
490450755-Chapter-2.ppt
490450755-Chapter-2.ppt490450755-Chapter-2.ppt
490450755-Chapter-2.ppt
ManiMala75
 
490450755-Chapter-2.ppt
490450755-Chapter-2.ppt490450755-Chapter-2.ppt
490450755-Chapter-2.ppt
ManiMala75
 
C programming presentation(final)
C programming presentation(final)C programming presentation(final)
C programming presentation(final)
aaravSingh41
 
Ad

Recently uploaded (20)

K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
Political History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptxPolitical History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdfBiophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
PKLI-Institute of Nursing and Allied Health Sciences Lahore , Pakistan.
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
dynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south Indiadynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south India
PrachiSontakke5
 
"Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules""Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules"
rupalinirmalbpharm
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
Kasdorf "Accessibility Essentials: A 2025 NISO Training Series, Session 5, Ac...
Kasdorf "Accessibility Essentials: A 2025 NISO Training Series, Session 5, Ac...Kasdorf "Accessibility Essentials: A 2025 NISO Training Series, Session 5, Ac...
Kasdorf "Accessibility Essentials: A 2025 NISO Training Series, Session 5, Ac...
National Information Standards Organization (NISO)
 
Real GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for SuccessReal GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for Success
Mark Soia
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
Introduction-to-Communication-and-Media-Studies-1736283331.pdf
Introduction-to-Communication-and-Media-Studies-1736283331.pdfIntroduction-to-Communication-and-Media-Studies-1736283331.pdf
Introduction-to-Communication-and-Media-Studies-1736283331.pdf
james5028
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
Grade 3 - English - Printable Worksheet (PDF Format)
Grade 3 - English - Printable Worksheet  (PDF Format)Grade 3 - English - Printable Worksheet  (PDF Format)
Grade 3 - English - Printable Worksheet (PDF Format)
Sritoma Majumder
 
Engage Donors Through Powerful Storytelling.pdf
Engage Donors Through Powerful Storytelling.pdfEngage Donors Through Powerful Storytelling.pdf
Engage Donors Through Powerful Storytelling.pdf
TechSoup
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
dynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south Indiadynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south India
PrachiSontakke5
 
"Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules""Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules"
rupalinirmalbpharm
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
Real GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for SuccessReal GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for Success
Mark Soia
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
Introduction-to-Communication-and-Media-Studies-1736283331.pdf
Introduction-to-Communication-and-Media-Studies-1736283331.pdfIntroduction-to-Communication-and-Media-Studies-1736283331.pdf
Introduction-to-Communication-and-Media-Studies-1736283331.pdf
james5028
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
Grade 3 - English - Printable Worksheet (PDF Format)
Grade 3 - English - Printable Worksheet  (PDF Format)Grade 3 - English - Printable Worksheet  (PDF Format)
Grade 3 - English - Printable Worksheet (PDF Format)
Sritoma Majumder
 
Engage Donors Through Powerful Storytelling.pdf
Engage Donors Through Powerful Storytelling.pdfEngage Donors Through Powerful Storytelling.pdf
Engage Donors Through Powerful Storytelling.pdf
TechSoup
 
Ad

Unit 2 introduction to c programming

  • 1. Unit - 2 Mithun D’Souza Assistant Professor, Department of Computer Science, PES Institute of Advanced Management Studies, Shivamogga
  • 2.  C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs.  C was originally first implemented on the DEC PDP-11 computer in 1972.  In 1978, Brian Kernighan and Dennis Ritchie produced the first publicly available description of C, now known as the K&R standard.  The UNIX operating system, the C compiler, and essentially all UNIX application programs have been written in C.
  • 3.  In 1988, the American National Standards Institute (ANSI) had formalized the C language.  C was invented to write UNIX operating system.  C is a successor of 'Basic Combined Programming Language' (BCPL) called B language.  Linux OS, PHP, and MySQL are written in C.  C has been written in assembly language
  • 5.  C has now become a widely used professional language for various reasons:  Easy to learn  Structured language  It produces efficient programs  It can handle low-level activities  It can be compiled on a variety of computer platforms
  • 6.  C was invented to write an operating system called UNIX.  C is a successor of B language which was introduced around the early 1970s.  The language was formalized in 1988 by the American National Standard Institute (ANSI).  The UNIX OS was totally written in C.  Today C is the most widely used and popular System Programming Language.  Most of the state-of-the-art software have been implemented using C.  Today's most popular Linux OS and RDBMS MySQL have been written in C.
  • 7.  C was initially used for system development work, particularly the programs that make-up the operating system.  C was adopted as a system development language because it produces code that runs nearly as fast as the code written in assembly language.  Operating Systems  Language Compilers  Assemblers  Text Editors  Print Spoolers  Network Drivers  Modern Programs  Databases  Language Interpreters  Utilities
  • 9.  In C, compiler is a special tool that compiles the program and converts it into the object file which is machine readable.  After the compilation process, the linker will combine different object files and creates a single executable file to run the program.
  • 10.  General purpose Programming Language  Structured Programming Language  Helps in the development of System Software  Rich set of Operators  Provides compact representation for expressions  Allows manipulation of internal processor registers  No rigid format: Any Number of statement can be typed in a single line  Portability: any C program can be run on different machines with little or no modification  Supports a rich set of data types  Very less number of reserved words  Pointer arithmetic and pointer manipulation  Ability to extend itself by adding functions to its library
  • 12.  System Software  Operating systems  Compilers  Assemblers  Editors  Loaders  Linkers  Application Software  Database Management Systems (DBMS)  Graphics Packages  Spread sheets  CAD/CAM applications  Word Processors  Office Automation Tools  Scientific and Engineering applications
  • 13. 1) Comment line 2) Preprocessor directive 3) Global variable declaration 4) main function( ) { Local variables; Statements; } User defined function ( ) { // user defined instructions/ statements }
  • 15.  It indicates the purpose of the program. It is represented as /*……………………………..*/  Comment line is used for increasing the readability of the program.  It is useful in explaining the program and generally used for documentation.  It is enclosed within the decimeters.  Comment line can be single or multiple line but should not be nested.  It can be anywhere in the program except inside string constant & character constant.
  • 16.  #include<stdio.h> tells the compiler to include information about the standard input/output library.  It is also used in symbolic constant such as #define PI 3.14(value).  The stdio.h (standard input output header file)  contains definition &declaration of system defined function such as  printf( ) - Printing on screen  scanf( ) - Reading data from user  pow( ) etc.  Generally printf() function used to display and scanf() function used to read value
  • 18.  This is the section where variable are declared globally  It can be access by all the functions used in the program.  And it is generally declared outside the function
  • 19.  It is the user defined function and every function has one main() function from where actually program is started and it is encloses within the pair of curly braces.  The main( ) function can be anywhere in the program but in general practice it is placed in the first position. Syntax : main() { …….. …….. …….. }
  • 20.  The main( ) function return value when it declared by data type as int main( ) { return 0 }  The main function does not return any value when void (means null/empty) as void main(void ) or void main() { printf (“C language”); } Output: C language
  • 21.  The program execution start with opening braces and end with closing brace.  And in between the two braces declaration part as well as executable part is mentioned.  And at the end of each line, the semi-colon is given which indicates statement termination. /*First c program with return statement*/ #include <stdio.h> int main (void) { printf ("welcome to c Programming language.n"); return 0; } Output: welcome to c programming language.
  • 22.  A compiler is a software program that analyzes a program developed in a particular computer language and then translates it into a form that is suitable for execution on a particular computer system.  The steps involves  entering,  compiling, and  executing a computer program  Which are developed in the C programming language  The typical Unix commands that would be entered from the command line
  • 24. #include <stdio.h> int main (void) { int v1, v2, sum; //v1,v2,sum are variables and int is data type declared v1 = 150; v2 = 25; sum = v1 + v2; printf ("The sum of %i and %i is= %in", v1, v2, sum); return 0; } Output: The sum of 150 and 25 is=175
  • 25.  Every programming language has its own character set to form the lexical elements.  C Language Character Sets are:  Alphabets  Digits  Special Characters
  • 27.  The basic and smallest units of C program are called C tokens.  Keywords  Identifiers  Constants  Strings  Operators  Special Symbols
  • 28.  There are certain words reserved for doing specific task, these words are known as reserved word or keywords.  These words are predefined and always written in lower case or small letter.  These keywords can’t be used as a variable name as it assigned with fixed meaning. Example
  • 29.  Identifiers are user defined word used to name of entities like variables, arrays, functions, structures etc.  Rules for naming identifiers are: 1) name should only consists of alphabets (both upper and lower case), digits and underscore (_) sign. 2) first characters should be alphabet or underscore 3) name should not be a keyword 4) since C is a case sensitive, the upper case and lower case considered differently, for example code, Code, CODE etc. are different identifiers. 5) identifiers are generally given in some meaningful name such as value, net_salary, age, data etc.
  • 30.  Constant is a any value that cannot be changed during program execution.  In C, any number, single character, or character string is known as a constant.  A constant is an entity that doesn’t change whereas a variable is an entity that may change. For example,  Number 50 represents a constant integer value.  The character string "Programming in C is fun.n" is an example of a constant character string.  C constants can be divided into two major categories:  Primary Constants  Secondary Constants
  • 32.  Numeric constant  Numeric constant consists of digits. It required minimum size of 2 bytes and max 4 bytes. ▪ Integer Constant ▪ Real Constant  Character constant  Character constant represented as a single character enclosed within a single quote.  These can be single digit, single special symbol or white spaces such as ‘9’,’c’,’$’, ‘ ’ etc.  String constant  Set of characters are called string and when sequence of characters are enclosed within a double quote.  Some examples are “sarathina” , “908”, “3”,” ”, “A” etc.  Symbolic constant  Symbolic constant is a name that substitute for a sequence of characters and, characters may be numeric, character or string constant.  #define name value, #define MAX 10, #define CH ‘b’, #define NAME “sony”
  • 33.  Variable is a data name which is used to store some data value or symbolic names for storing program computations and results.  The value of the variable can be changed during the execution.  The rule for naming the variables is same as the naming identifier.  Before used in the program it must be declared.  Declaration of variables specify its name, data types and range of the value that variables can store depends upon its data types. Syntax: int a; char c; float f;
  • 34.  When we assign any initial value to variable during the declaration, is called initialization of variables.  When variable is declared but contain undefined value then it is called garbage value.  The variable is initialized with the assignment operator such as Data type variable name = constant; Example: int a=20; or int a; a=20;
  • 35.  Data types refer to an extensive system used for declaring variables or functions of different types before its use.  The type of a variable determines how much space it occupies in storage and how the bit pattern stored is interpreted.  The value of a variable can be changed any time.  C has the following 4 types of data types  basic built-in data types: int, float, double, char  Enumeration data type: enum  Derived data type: pointer, array, structure, union  Void data type: void
  • 36.  A variable declared to be of type int can be used to contain integral values only  That is, values that do not contain decimal places.  A variable declared to be of type float can be used for storing floating- point numbers (values containing decimal places).  The double type is the same as type float, only with roughly twice the precision.  The char data type can be used to store a single character, such as the letter a, the digit character 6, or a semicolon similarly  A variable declared char can only store character type value.
  • 37.  There are two types of type qualifier in c  Size qualifier: short, long  Sign qualifier: signed, unsigned  When the qualifier unsigned is used the number is always positive, and when signed is used number may be positive or negative.  If the sign qualifier is not mentioned, then by default sign qualifier is assumed.  The range of values for signed data types is less than that of unsigned data type.  Because in signed type, the left most bit is used to represent sign, while in unsigned type this bit is also used to represent the value.
  • 39. C O M P L E T E D