SlideShare a Scribd company logo
Introduction to C
Introduction to C language – Structure of C program - Character set –
token – identifiers – reserved words – Comments - data types –
constants – printf() function - variables – scanf() function - operators –
expression – declaration statement – assignment statement -
conversion of algorithm in to program – Solving simple problems
involving arithmetic computations and sequential logic to solve.
1
WHY WE LEARN C?
• C language is the most commonly used programming language.
• It is used for writing operating systems.
• UNIX was the first operating system written in C.
• Later Microsoft Windows, Mac OS X, and GNU/Linux were all written in
C.
• Not only is C the language of operating systems, it is the precursor and
inspiration for almost all of the most popular high-level languages available
today.
• In fact, Perl, PHP, Python and Ruby are all written in C.
FEATURES OF C LANGUAGE
• Robust language, which can be used to write any complex
program.
• Well-suited for writing both system software and business
applications.
• Dynamic memory allocation
• C is highly portable. This means that ‘C’ programs written from one
computer can be run on another computer with no modification.
• A ‘C’ program is basically a collection of functions that are supported
by the ‘C’ library
FEATURES OF C LANGUAGE CONT.…
• Program written in C language are efficient & fast.
• ‘C’ is a free form language.
• Case sensitive.
• C has 32 keywords.
• ‘C’ is a structure or procedural programming language that are
use top-down approach.
• Compactness & Reusability
Advantages of C
• General Purpose Language
• Portable Language
• C Provides a collection of Library files
• It support good graphics
• It supports System Programming
• It supports number of operators
• It supports arrays, pointers ,structures and union
• It is used to implementing Data Structure
• It supports structured programming and modularity
Disadvantages in C
•There is no run type checking in c Language
•Non Uniformity in associativity
•It uses same operator for multiple purpose
•It does not support exception handling
•No direct input and output facility
Valid Steps in C Language
• Every step should end with semicolon
• A function name is to be followed by a pair of paranthesis and
arguments are separated by commas
• Single quote(‘) is used for character constant and double quote
(“) is used for string constant
• Compound statements are enclosed within curly braces { }
• Comments are written to improve the readability and
understanding of programs(/*...*/)
Valid Steps in C Language
•All statements should be written in lower case
•Proper header file like <stdio.h> ,<conio.h> are to be used for
systematic programming and linking
•Uppercase characters are used for symbolic constants
•Blank spaces can be inserted between words
•Blank spaces should not be used while declaring a variable
,keyword ,constant and function
•User can write one or more statements in a line separated by
semicolon
•The number of opening and closing braces should be balanced
•Example: a=b+c;m=p*q;
Structure of C program
•C Program is divided into different sections.
•There are six main sections to a basic c program.
The six sections are,
•Documentation
•Link
•Definition
•Global Declarations
•Main Functions
•Subprograms
Structure of C program
Structure of C program
Structure of C program
Structure of C program
Structure of C program
Documentation Section
The documentation section is the part of the program where the
programmer gives the details associated with the program. He/she
usually gives the name of the program, the details of the author and
other details like the time of coding and description. It gives anyone
reading the code the overview of the code.
Example
/**
* File Name: Helloworld.c
* Author: SIT
* description: a program to display hello world
* no input needed
*/
Structure of C program
Link Section
This part of the code is used to declare all the header files that will be
used in the program. This leads to the compiler being told to link the
header files to the system libraries.
Example
#include<stdio.h>
Definition Section
In this section, we define different constants. The keyword define is
used in this part.
#define PI=3.14
Structure of C program
Global Declaration Section
This part of the code is the part where the global variables are declared.
All the global variable used are declared in this part. The user-defined
functions are also declared in this part of the code.
EXAMPLE
float area(float r);
int a=7;
Structure of C program
Main Function Section
Every C-programs needs to have the main function. Each main function
contains 2 parts. A declaration part and an Execution part. The
declaration part is the part where all the variables are declared. The
execution part begins with the curly brackets and ends with the curly
close bracket. Both the declaration and execution part are inside the
curly braces.
EXAMPLE
int main(void)
{
int a=10;
printf(" %d", a);
return 0;
}
Structure of C program
Sub Program Section
• All the user-defined functions are defined in this section of the
program.
• EXAMPLE
• int add(int a, int b)
• {
• return a+b;
• }
Structure of C program
• Sample Program
• The C program here will find the area of a circle using a user-defined function and a global variable pi holding the value of pi
• /** File Name: areaofcircle.c //Documentation section
• * Author: Manthan Naik
• * date: 09/08/2019
• * description: a program to calculate area of circle
• *user enters the radius
• **/
• #include<stdio.h> //link section
• #define pi 3.14; //definition section
• float area(float r); //global declaration
• int main() //main function
• {
• float r;
• printf(" Enter the radius:n");
• scanf("%f",&r);
• printf("the area is: %f",area(r));
• return 0;
• }
• float area(float r)
• {
• return pi * r * r; //sub program
• }
• Output
Character set
• Character is a part of a word ,sentences or paragraph.
• A character set defines the valid characters that can be used in
source programs or interpreted when a program is running.
• The source character set is the set of characters available for the
source text.
C Tokens
Keywords
•Reserved words
•32 keywords
•Fixed meaning which are already defined. It cannot be altered
Identifiers
• C identifiers represent the name in the C program, for example,
variables, functions, arrays, structures, unions, labels, etc.
• An identifier can be composed of letters such as uppercase,
lowercase letters, underscore, digits, but the starting letter should be
either an alphabet or an underscore.
• Example
Identifiers
• Valid Identifiers
name,age,sub,tot_marks,a10
• Invalid Identifiers
2sub,$price,date of birth,auto
Constants
Constants
Comments
Multiline Comments
Variables
• Each variable in C has a specific type, which determines the size
and layout of the variable's memory; the range of values that can be
stored within that memory; and the set of operations that can be
applied to the variable.
• Syntax:
• Data_type variable_name;
• Declaration of Variables : int a=20; int a,b,c;
• float num=10.5;
Rules for declare the Variables

More Related Content

What's hot

Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
Akhil Kaushik
 
Introduction to c language | History of C language
Introduction to c language | History of C languageIntroduction to c language | History of C language
Introduction to c language | History of C language
simplidigital
 
computer languages
computer languagescomputer languages
computer languages
Rajendran
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
Ahmed Raza
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming Fundamentals
Trivuz ত্রিভুজ
 
Introduction to Procedural Programming in C++
Introduction to Procedural Programming in C++Introduction to Procedural Programming in C++
Introduction to Procedural Programming in C++
Salahaddin University-Erbil
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
Manoj Tyagi
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
Mukesh Tekwani
 
Introduction of c programming
Introduction of c programmingIntroduction of c programming
Introduction of c programming
Tarun Sharma
 
Introduction to Python IDLE | IDLE Tutorial | Edureka
Introduction to Python IDLE | IDLE Tutorial | EdurekaIntroduction to Python IDLE | IDLE Tutorial | Edureka
Introduction to Python IDLE | IDLE Tutorial | Edureka
Edureka!
 
CONDITIONAL STATEMENT IN C LANGUAGE
CONDITIONAL STATEMENT IN C LANGUAGECONDITIONAL STATEMENT IN C LANGUAGE
CONDITIONAL STATEMENT IN C LANGUAGE
Ideal Eyes Business College
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
programming9
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite Automata
Ratnakar Mikkili
 
Context Free Grammar
Context Free GrammarContext Free Grammar
Context Free Grammar
Akhil Kaushik
 
Context free grammars
Context free grammarsContext free grammars
Context free grammarsRonak Thakkar
 
fundamentals of c
fundamentals of cfundamentals of c
fundamentals of c
Vijayalaxmi Wakode
 

What's hot (20)

Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
Introduction to c language | History of C language
Introduction to c language | History of C languageIntroduction to c language | History of C language
Introduction to c language | History of C language
 
computer languages
computer languagescomputer languages
computer languages
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
 
C LANGUAGE NOTES
C LANGUAGE NOTESC LANGUAGE NOTES
C LANGUAGE NOTES
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming Fundamentals
 
Structure of a C program
Structure of a C programStructure of a C program
Structure of a C program
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
Introduction to Procedural Programming in C++
Introduction to Procedural Programming in C++Introduction to Procedural Programming in C++
Introduction to Procedural Programming in C++
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
 
Introduction of c programming
Introduction of c programmingIntroduction of c programming
Introduction of c programming
 
Introduction to Python IDLE | IDLE Tutorial | Edureka
Introduction to Python IDLE | IDLE Tutorial | EdurekaIntroduction to Python IDLE | IDLE Tutorial | Edureka
Introduction to Python IDLE | IDLE Tutorial | Edureka
 
CONDITIONAL STATEMENT IN C LANGUAGE
CONDITIONAL STATEMENT IN C LANGUAGECONDITIONAL STATEMENT IN C LANGUAGE
CONDITIONAL STATEMENT IN C LANGUAGE
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite Automata
 
Context Free Grammar
Context Free GrammarContext Free Grammar
Context Free Grammar
 
Context free grammars
Context free grammarsContext free grammars
Context free grammars
 
fundamentals of c
fundamentals of cfundamentals of c
fundamentals of c
 

Similar to Introduction of c programming unit-ii ppt

Copy of UNIT 2 -- Basics Of Programming.pptx
Copy of UNIT 2 -- Basics Of Programming.pptxCopy of UNIT 2 -- Basics Of Programming.pptx
Copy of UNIT 2 -- Basics Of Programming.pptx
rahulrajbhar06478
 
Learning the C Language
Learning the C LanguageLearning the C Language
Learning the C Language
nTier Custom Solutions
 
Unit 2 introduction to c programming
Unit 2   introduction to c programmingUnit 2   introduction to c programming
Unit 2 introduction to c programming
Mithun DSouza
 
c-introduction.pptx
c-introduction.pptxc-introduction.pptx
c-introduction.pptx
Mangala R
 
C pdf
C pdfC pdf
C pdf
amit9765
 
Rr
RrRr
Rr
VK AG
 
Introduction to the c programming language (amazing and easy book for beginners)
Introduction to the c programming language (amazing and easy book for beginners)Introduction to the c programming language (amazing and easy book for beginners)
Introduction to the c programming language (amazing and easy book for beginners)
mujeeb memon
 
358 33 powerpoint-slides_1-introduction-c_chapter-1
358 33 powerpoint-slides_1-introduction-c_chapter-1358 33 powerpoint-slides_1-introduction-c_chapter-1
358 33 powerpoint-slides_1-introduction-c_chapter-1
sumitbardhan
 
C programming
C programmingC programming
C programming
KarthicaMarasamy
 
Understanding C and its Applications.pdf
Understanding C and its Applications.pdfUnderstanding C and its Applications.pdf
Understanding C and its Applications.pdf
AdeleHansley
 
Unit ii
Unit   iiUnit   ii
Unit ii
sathisaran
 
8844632.ppt
8844632.ppt8844632.ppt
8844632.ppt
SushmaG48
 
Unit-1 (introduction to c language).pptx
Unit-1 (introduction to c language).pptxUnit-1 (introduction to c language).pptx
Unit-1 (introduction to c language).pptx
saivasu4
 
Chapter-2 edited on Programming in Can refer this ppt
Chapter-2 edited on Programming in Can refer this pptChapter-2 edited on Programming in Can refer this ppt
Chapter-2 edited on Programming in Can refer this ppt
ANISHYAPIT
 
c_pro_introduction.pptx
c_pro_introduction.pptxc_pro_introduction.pptx
c_pro_introduction.pptx
RohitRaj744272
 
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
 

Similar to Introduction of c programming unit-ii ppt (20)

Copy of UNIT 2 -- Basics Of Programming.pptx
Copy of UNIT 2 -- Basics Of Programming.pptxCopy of UNIT 2 -- Basics Of Programming.pptx
Copy of UNIT 2 -- Basics Of Programming.pptx
 
C language unit-1
C language unit-1C language unit-1
C language unit-1
 
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDYC LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
 
C languaGE UNIT-1
C languaGE UNIT-1C languaGE UNIT-1
C languaGE UNIT-1
 
Learning the C Language
Learning the C LanguageLearning the C Language
Learning the C Language
 
Unit 2 introduction to c programming
Unit 2   introduction to c programmingUnit 2   introduction to c programming
Unit 2 introduction to c programming
 
c-introduction.pptx
c-introduction.pptxc-introduction.pptx
c-introduction.pptx
 
C pdf
C pdfC pdf
C pdf
 
Rr
RrRr
Rr
 
Introduction to the c programming language (amazing and easy book for beginners)
Introduction to the c programming language (amazing and easy book for beginners)Introduction to the c programming language (amazing and easy book for beginners)
Introduction to the c programming language (amazing and easy book for beginners)
 
358 33 powerpoint-slides_1-introduction-c_chapter-1
358 33 powerpoint-slides_1-introduction-c_chapter-1358 33 powerpoint-slides_1-introduction-c_chapter-1
358 33 powerpoint-slides_1-introduction-c_chapter-1
 
C programming
C programmingC programming
C programming
 
Understanding C and its Applications.pdf
Understanding C and its Applications.pdfUnderstanding C and its Applications.pdf
Understanding C and its Applications.pdf
 
Unit ii
Unit   iiUnit   ii
Unit ii
 
8844632.ppt
8844632.ppt8844632.ppt
8844632.ppt
 
Unit-1 (introduction to c language).pptx
Unit-1 (introduction to c language).pptxUnit-1 (introduction to c language).pptx
Unit-1 (introduction to c language).pptx
 
Chapter-2 edited on Programming in Can refer this ppt
Chapter-2 edited on Programming in Can refer this pptChapter-2 edited on Programming in Can refer this ppt
Chapter-2 edited on Programming in Can refer this ppt
 
c_pro_introduction.pptx
c_pro_introduction.pptxc_pro_introduction.pptx
c_pro_introduction.pptx
 
490450755-Chapter-2.ppt
490450755-Chapter-2.ppt490450755-Chapter-2.ppt
490450755-Chapter-2.ppt
 
490450755-Chapter-2.ppt
490450755-Chapter-2.ppt490450755-Chapter-2.ppt
490450755-Chapter-2.ppt
 

Recently uploaded

A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 

Recently uploaded (20)

A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 

Introduction of c programming unit-ii ppt

  • 1. Introduction to C Introduction to C language – Structure of C program - Character set – token – identifiers – reserved words – Comments - data types – constants – printf() function - variables – scanf() function - operators – expression – declaration statement – assignment statement - conversion of algorithm in to program – Solving simple problems involving arithmetic computations and sequential logic to solve. 1
  • 2. WHY WE LEARN C? • C language is the most commonly used programming language. • It is used for writing operating systems. • UNIX was the first operating system written in C. • Later Microsoft Windows, Mac OS X, and GNU/Linux were all written in C. • Not only is C the language of operating systems, it is the precursor and inspiration for almost all of the most popular high-level languages available today. • In fact, Perl, PHP, Python and Ruby are all written in C.
  • 3. FEATURES OF C LANGUAGE • Robust language, which can be used to write any complex program. • Well-suited for writing both system software and business applications. • Dynamic memory allocation • C is highly portable. This means that ‘C’ programs written from one computer can be run on another computer with no modification. • A ‘C’ program is basically a collection of functions that are supported by the ‘C’ library
  • 4. FEATURES OF C LANGUAGE CONT.… • Program written in C language are efficient & fast. • ‘C’ is a free form language. • Case sensitive. • C has 32 keywords. • ‘C’ is a structure or procedural programming language that are use top-down approach. • Compactness & Reusability
  • 5. Advantages of C • General Purpose Language • Portable Language • C Provides a collection of Library files • It support good graphics • It supports System Programming • It supports number of operators • It supports arrays, pointers ,structures and union • It is used to implementing Data Structure • It supports structured programming and modularity
  • 6. Disadvantages in C •There is no run type checking in c Language •Non Uniformity in associativity •It uses same operator for multiple purpose •It does not support exception handling •No direct input and output facility
  • 7. Valid Steps in C Language • Every step should end with semicolon • A function name is to be followed by a pair of paranthesis and arguments are separated by commas • Single quote(‘) is used for character constant and double quote (“) is used for string constant • Compound statements are enclosed within curly braces { } • Comments are written to improve the readability and understanding of programs(/*...*/)
  • 8. Valid Steps in C Language •All statements should be written in lower case •Proper header file like <stdio.h> ,<conio.h> are to be used for systematic programming and linking •Uppercase characters are used for symbolic constants •Blank spaces can be inserted between words •Blank spaces should not be used while declaring a variable ,keyword ,constant and function •User can write one or more statements in a line separated by semicolon •The number of opening and closing braces should be balanced •Example: a=b+c;m=p*q;
  • 9. Structure of C program •C Program is divided into different sections. •There are six main sections to a basic c program. The six sections are, •Documentation •Link •Definition •Global Declarations •Main Functions •Subprograms
  • 10. Structure of C program
  • 11. Structure of C program
  • 12. Structure of C program
  • 13. Structure of C program
  • 14. Structure of C program Documentation Section The documentation section is the part of the program where the programmer gives the details associated with the program. He/she usually gives the name of the program, the details of the author and other details like the time of coding and description. It gives anyone reading the code the overview of the code. Example /** * File Name: Helloworld.c * Author: SIT * description: a program to display hello world * no input needed */
  • 15. Structure of C program Link Section This part of the code is used to declare all the header files that will be used in the program. This leads to the compiler being told to link the header files to the system libraries. Example #include<stdio.h> Definition Section In this section, we define different constants. The keyword define is used in this part. #define PI=3.14
  • 16. Structure of C program Global Declaration Section This part of the code is the part where the global variables are declared. All the global variable used are declared in this part. The user-defined functions are also declared in this part of the code. EXAMPLE float area(float r); int a=7;
  • 17. Structure of C program Main Function Section Every C-programs needs to have the main function. Each main function contains 2 parts. A declaration part and an Execution part. The declaration part is the part where all the variables are declared. The execution part begins with the curly brackets and ends with the curly close bracket. Both the declaration and execution part are inside the curly braces. EXAMPLE int main(void) { int a=10; printf(" %d", a); return 0; }
  • 18. Structure of C program Sub Program Section • All the user-defined functions are defined in this section of the program. • EXAMPLE • int add(int a, int b) • { • return a+b; • }
  • 19. Structure of C program • Sample Program • The C program here will find the area of a circle using a user-defined function and a global variable pi holding the value of pi • /** File Name: areaofcircle.c //Documentation section • * Author: Manthan Naik • * date: 09/08/2019 • * description: a program to calculate area of circle • *user enters the radius • **/ • #include<stdio.h> //link section • #define pi 3.14; //definition section • float area(float r); //global declaration • int main() //main function • { • float r; • printf(" Enter the radius:n"); • scanf("%f",&r); • printf("the area is: %f",area(r)); • return 0; • } • float area(float r) • { • return pi * r * r; //sub program • } • Output
  • 20. Character set • Character is a part of a word ,sentences or paragraph. • A character set defines the valid characters that can be used in source programs or interpreted when a program is running. • The source character set is the set of characters available for the source text.
  • 22. Keywords •Reserved words •32 keywords •Fixed meaning which are already defined. It cannot be altered
  • 23. Identifiers • C identifiers represent the name in the C program, for example, variables, functions, arrays, structures, unions, labels, etc. • An identifier can be composed of letters such as uppercase, lowercase letters, underscore, digits, but the starting letter should be either an alphabet or an underscore. • Example
  • 24. Identifiers • Valid Identifiers name,age,sub,tot_marks,a10 • Invalid Identifiers 2sub,$price,date of birth,auto
  • 29. Variables • Each variable in C has a specific type, which determines the size and layout of the variable's memory; the range of values that can be stored within that memory; and the set of operations that can be applied to the variable. • Syntax: • Data_type variable_name; • Declaration of Variables : int a=20; int a,b,c; • float num=10.5;
  • 30. Rules for declare the Variables