際際滷

際際滷Share a Scribd company logo
Unit No-2
Basics of C Programming
2.1 Introduction to C.
2.2 Data Concepts.
2.3 Basic Input Output.
2.1 Introduction to C
 History of C.
 General Structure of C program.
 Header files.
 Main Function.
History of C Language
  Developed at AT&Ts Bell Laboratories of USA in 1972
  Designed and written by a man named Dennis Ritchie
  Most of its principles and ideas were taken from the earlier
language B, BCPL and CPL
  Languages before C are PL/I, ALGOL, FORTRAN, Pascal,
APL, B
Unit No 2.pptx   Basic s of C Programming
Importance of C
  General purpose language but normally used for system
programming
  Robust due to rich set of built in functions and operaters for
writing complex program
  C is highly portable i.e. platform independent
  Can add our own functions to C library
Structure of C program.
 A 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
Documentation Section
 The documentation section is the part of the program where the programmer
gives the details associated with the program. He 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: om Sai
date: 09/08/2021
*/
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
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.
float b;
int a=7;
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.
int main(void)
{
int a=10;
printf(" %d", a);
return 0;
}
Sub Program Section
All the user-defined functions are defined in this section of the program.
int add(int a, int b)
{
return a+b;
}
Header Files
In C language, header files contain the set of predefined standard library functions. The #include preprocessing
directive is used to include the header files with .h extension in the program.
 Here is the table that displays some of the header files in C language,
Header Files Description
1. stdio.h Input/Output functions
2. conio.h Console Input/Output functions
3. stdlib.h General utility functions
4. math.h Mathematics functions
5. string.h String functions
6. ctype.h Character handling functions
7. time.h Date and time functions
8. float.h Limits of float types
9. limits.h Size of basic types
10.wctype.h Functions to determine the type contained in wide character data.
2.2 Data Concepts
 Character Set
 Tokens
 Keywords
 Identifires
 Variables
 Constants
 Datatypes
 C Operators
 Arithmetic Operators
C CharacterSet
 A character denotes any alphabet, digit or special symbol used
to represent information.
 Alphabets A,B,..,Y,Z a,b,,y,z
 Digits 0,1,2, 3,4,5,6, 7,8,9
 Specialsymbols ~!@#%^&*()_-+=| {} [ ]:; "'<>,.?/
Tokens
 Smallest individual units are known as C tokens.
 Six Types are
1. Keywords:- float, int, while
2. Identifiers: - name of variables and functions
3. Constants: -15.5, 10
4. Strings: - Abc, year
5. Special Symbols: - {}, @,
6. Operators: - +,-,*,/
Unit No 2.pptx   Basic s of C Programming
Keywords
 Keywords are the words whose
meaning has already been explained to
the C compiler.
 The following names are reserved by
the C language. Their meaning is
already defined, and they cannot be re-
defined.
 Identifiers refer to the names of variables, functions and arrays, these are user-
defined names
 Constants fixed values that do not change during the execution of a program.
 Variables is a data name that used to store a data value. Value stored in a
variable may change during program execution.
 Data types
  The datatype determines what kinds of values a variable can store and what
kind of operations can be performed on variables.
 Every variable used in a program must have a data type
 Two types of data types Primary and Secondary
1.  Primary Data Types : - integer, float, character
2.  Secondary Data Types :- array, pointer, structure
Unit No 2.pptx   Basic s of C Programming
C Operators
1.  Arithmetic
2.  Logical
3. Assignment 
4. Relational
5. Increment And Decrement 
6. Conditional 
7. Bit Wise
8. Special
Arithmetic Operators
The basic operators for performing arithmetic:
9. + addition
10.- subtraction
11.* multiplication
12. / division
13.% modulus (remainder)
Declaring Variable
Variable Declaration
  Every variable in C must be declared before using it in program
  Variables are declared at the start of body of function of main function
  Declaration tells the compiler what the variable name is.
  It specifies what type of data value the variable will hold and what kind of operations can be
 performed on variables.
  The syntax is : - data_typename_of_variable
  E.g. int number, amount, balance; for declaring integer type variables
  E.g. float percent; for declaring float type variables
  E.g. char grade; for declaring char type variables
Variable Initialization :- Means assigning an initial value to variable.
 
E.g. int num = 1 ; // Variable Declaration and Initialization
Declaring Variable as Constants (const):- E.g. const int class_size = 40;

  keeps value of variable constant throughout program
2.3 Basic Input Output.
 Input and Output Statements using printf() and scanf().
printf( )
Printf() is used to print only messege or values of variables.General form of printf( ) function is,
printf ( "format string", list of variables ) ; 
 %f for printing real values
 %d for printing integer values
 %c for printing character values
 printf( ) can not only print values of variables, it can also print the result of an expression
 e.g. to print welcome messege the printf() statements is as follows.
printf(Welcome to Sanjivani KBP Polytechnic);
scanf()
  scanf( ) allows us to enter data from keyboard that will be formatted in a certain way.
  The general form of scanf( ) statement is as follows:
 scanf ( "format string", list of addresses of variables ) ;
 For example:
 scanf ( "%d ", &c ) ;
 Addresses of variables (addresses are obtained by using & the address of operator) is send to scanf( ) function. This is
necessary because the values received from keyboard must be dropped into variables corresponding to these addresses.
The values that are supplied through the keyboard must be separated by either blank(s), tab(s), or newline(s).
 The ampersand (&) before the variables in the scanf( ) function is a must. & is an Address of
operator. It gives the location number used by the variable in memory. When we say &a, we are
telling scanf( ) at which memory location should it store the value supplied by the user from the
keyboard.
Escape Sequences

More Related Content

Similar to Unit No 2.pptx Basic s of C Programming (20)

Fundamentals of Data Structures Unit 1.pptx
Fundamentals of Data Structures Unit 1.pptxFundamentals of Data Structures Unit 1.pptx
Fundamentals of Data Structures Unit 1.pptx
Vigneshkumar Ponnusamy
history of c.ppt
history of c.ppthistory of c.ppt
history of c.ppt
arpanabharani
unit2.pptx
unit2.pptxunit2.pptx
unit2.pptx
sscprep9
c-introduction.pptx
c-introduction.pptxc-introduction.pptx
c-introduction.pptx
Mangala R
Learning the C Language
Learning the C LanguageLearning the C Language
Learning the C Language
nTier Custom Solutions
c programming session 1.pptx
c programming session 1.pptxc programming session 1.pptx
c programming session 1.pptx
RSathyaPriyaCSEKIOT
C
CC
C
Jerin John
UNIT-1 notes(Data Types Variables Operations Expressions and Statements...
UNIT-1 notes(Data Types  Variables  Operations  Expressions and Statements...UNIT-1 notes(Data Types  Variables  Operations  Expressions and Statements...
UNIT-1 notes(Data Types Variables Operations Expressions and Statements...
RSathyaPriyaCSEKIOT
EC2311-Data Structures and C Programming
EC2311-Data Structures and C ProgrammingEC2311-Data Structures and C Programming
EC2311-Data Structures and C Programming
Padma Priya
Fundamentals of computers - C Programming
Fundamentals of computers - C ProgrammingFundamentals of computers - C Programming
Fundamentals of computers - C Programming
MSridhar18
2. Introduction to 'C' Language (1).pptx
2. Introduction to 'C' Language (1).pptx2. Introduction to 'C' Language (1).pptx
2. Introduction to 'C' Language (1).pptx
AkshatMuke1
Programming Fundamental 際際滷 lecture no.2 (Section E)
Programming Fundamental 際際滷 lecture no.2 (Section E)Programming Fundamental 際際滷 lecture no.2 (Section E)
Programming Fundamental 際際滷 lecture no.2 (Section E)
Arslan Hussain
C language ppt
C language pptC language ppt
C language ppt
辰湛r奪v J炭単棚j奪
c-programming
c-programmingc-programming
c-programming
Zulhazmi Harith
C cpluplus 2
C cpluplus 2C cpluplus 2
C cpluplus 2
sanya6900
C programming
C programmingC programming
C programming
PralhadKhanal1
C PROGRAMING.pptx
C PROGRAMING.pptxC PROGRAMING.pptx
C PROGRAMING.pptx
MohammedtajuddinTaju
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
CP c++ programing project Unit 1 intro.pdf
CP c++ programing project  Unit 1 intro.pdfCP c++ programing project  Unit 1 intro.pdf
CP c++ programing project Unit 1 intro.pdf
ShivamYadav886008
Introduction of c programming unit-ii ppt
Introduction of  c programming unit-ii pptIntroduction of  c programming unit-ii ppt
Introduction of c programming unit-ii ppt
JStalinAsstProfessor
Fundamentals of Data Structures Unit 1.pptx
Fundamentals of Data Structures Unit 1.pptxFundamentals of Data Structures Unit 1.pptx
Fundamentals of Data Structures Unit 1.pptx
Vigneshkumar Ponnusamy
unit2.pptx
unit2.pptxunit2.pptx
unit2.pptx
sscprep9
c-introduction.pptx
c-introduction.pptxc-introduction.pptx
c-introduction.pptx
Mangala R
UNIT-1 notes(Data Types Variables Operations Expressions and Statements...
UNIT-1 notes(Data Types  Variables  Operations  Expressions and Statements...UNIT-1 notes(Data Types  Variables  Operations  Expressions and Statements...
UNIT-1 notes(Data Types Variables Operations Expressions and Statements...
RSathyaPriyaCSEKIOT
EC2311-Data Structures and C Programming
EC2311-Data Structures and C ProgrammingEC2311-Data Structures and C Programming
EC2311-Data Structures and C Programming
Padma Priya
Fundamentals of computers - C Programming
Fundamentals of computers - C ProgrammingFundamentals of computers - C Programming
Fundamentals of computers - C Programming
MSridhar18
2. Introduction to 'C' Language (1).pptx
2. Introduction to 'C' Language (1).pptx2. Introduction to 'C' Language (1).pptx
2. Introduction to 'C' Language (1).pptx
AkshatMuke1
Programming Fundamental 際際滷 lecture no.2 (Section E)
Programming Fundamental 際際滷 lecture no.2 (Section E)Programming Fundamental 際際滷 lecture no.2 (Section E)
Programming Fundamental 際際滷 lecture no.2 (Section E)
Arslan Hussain
C cpluplus 2
C cpluplus 2C cpluplus 2
C cpluplus 2
sanya6900
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
CP c++ programing project Unit 1 intro.pdf
CP c++ programing project  Unit 1 intro.pdfCP c++ programing project  Unit 1 intro.pdf
CP c++ programing project Unit 1 intro.pdf
ShivamYadav886008
Introduction of c programming unit-ii ppt
Introduction of  c programming unit-ii pptIntroduction of  c programming unit-ii ppt
Introduction of c programming unit-ii ppt
JStalinAsstProfessor

More from Vaibhav Parjane (13)

Advantages and disadvantages of algorithm.pptx
Advantages and disadvantages of algorithm.pptxAdvantages and disadvantages of algorithm.pptx
Advantages and disadvantages of algorithm.pptx
Vaibhav Parjane
Examples of Algorithms : Introduction to C.pptx
Examples of Algorithms : Introduction to C.pptxExamples of Algorithms : Introduction to C.pptx
Examples of Algorithms : Introduction to C.pptx
Vaibhav Parjane
Topic 1.1 Fundamentals of Algorithm.pptx
Topic 1.1 Fundamentals of Algorithm.pptxTopic 1.1 Fundamentals of Algorithm.pptx
Topic 1.1 Fundamentals of Algorithm.pptx
Vaibhav Parjane
Unit no 1(Fundamentals of Algorithm).pptx
Unit no 1(Fundamentals of Algorithm).pptxUnit no 1(Fundamentals of Algorithm).pptx
Unit no 1(Fundamentals of Algorithm).pptx
Vaibhav Parjane
Unit 1(1).pptx Program Logic Development
Unit 1(1).pptx Program Logic DevelopmentUnit 1(1).pptx Program Logic Development
Unit 1(1).pptx Program Logic Development
Vaibhav Parjane
Unit 2 Searching and Sorting Technique.pptx
Unit 2 Searching and Sorting Technique.pptxUnit 2 Searching and Sorting Technique.pptx
Unit 2 Searching and Sorting Technique.pptx
Vaibhav Parjane
PPT.pptx Searching and Sorting Techniques
PPT.pptx Searching and Sorting TechniquesPPT.pptx Searching and Sorting Techniques
PPT.pptx Searching and Sorting Techniques
Vaibhav Parjane
unit 2 First.pptx Searching - Linear and Binary Search
unit 2 First.pptx Searching - Linear and Binary Searchunit 2 First.pptx Searching - Linear and Binary Search
unit 2 First.pptx Searching - Linear and Binary Search
Vaibhav Parjane
unit 1 SIXTH.pptx Algorithm Complexity Time
unit 1 SIXTH.pptx Algorithm Complexity Timeunit 1 SIXTH.pptx Algorithm Complexity Time
unit 1 SIXTH.pptx Algorithm Complexity Time
Vaibhav Parjane
Operations on Data Structure- Several Operation performed on DS
Operations on Data Structure- Several Operation performed on DSOperations on Data Structure- Several Operation performed on DS
Operations on Data Structure- Several Operation performed on DS
Vaibhav Parjane
Classification of Data Structure -Linear and Non Linear
Classification of Data Structure -Linear and Non LinearClassification of Data Structure -Linear and Non Linear
Classification of Data Structure -Linear and Non Linear
Vaibhav Parjane
Need of Data Structure & Abstract Data Type
Need of Data Structure & Abstract Data TypeNeed of Data Structure & Abstract Data Type
Need of Data Structure & Abstract Data Type
Vaibhav Parjane
Introduction to data & Data Structure Definition
Introduction to data & Data Structure DefinitionIntroduction to data & Data Structure Definition
Introduction to data & Data Structure Definition
Vaibhav Parjane
Advantages and disadvantages of algorithm.pptx
Advantages and disadvantages of algorithm.pptxAdvantages and disadvantages of algorithm.pptx
Advantages and disadvantages of algorithm.pptx
Vaibhav Parjane
Examples of Algorithms : Introduction to C.pptx
Examples of Algorithms : Introduction to C.pptxExamples of Algorithms : Introduction to C.pptx
Examples of Algorithms : Introduction to C.pptx
Vaibhav Parjane
Topic 1.1 Fundamentals of Algorithm.pptx
Topic 1.1 Fundamentals of Algorithm.pptxTopic 1.1 Fundamentals of Algorithm.pptx
Topic 1.1 Fundamentals of Algorithm.pptx
Vaibhav Parjane
Unit no 1(Fundamentals of Algorithm).pptx
Unit no 1(Fundamentals of Algorithm).pptxUnit no 1(Fundamentals of Algorithm).pptx
Unit no 1(Fundamentals of Algorithm).pptx
Vaibhav Parjane
Unit 1(1).pptx Program Logic Development
Unit 1(1).pptx Program Logic DevelopmentUnit 1(1).pptx Program Logic Development
Unit 1(1).pptx Program Logic Development
Vaibhav Parjane
Unit 2 Searching and Sorting Technique.pptx
Unit 2 Searching and Sorting Technique.pptxUnit 2 Searching and Sorting Technique.pptx
Unit 2 Searching and Sorting Technique.pptx
Vaibhav Parjane
PPT.pptx Searching and Sorting Techniques
PPT.pptx Searching and Sorting TechniquesPPT.pptx Searching and Sorting Techniques
PPT.pptx Searching and Sorting Techniques
Vaibhav Parjane
unit 2 First.pptx Searching - Linear and Binary Search
unit 2 First.pptx Searching - Linear and Binary Searchunit 2 First.pptx Searching - Linear and Binary Search
unit 2 First.pptx Searching - Linear and Binary Search
Vaibhav Parjane
unit 1 SIXTH.pptx Algorithm Complexity Time
unit 1 SIXTH.pptx Algorithm Complexity Timeunit 1 SIXTH.pptx Algorithm Complexity Time
unit 1 SIXTH.pptx Algorithm Complexity Time
Vaibhav Parjane
Operations on Data Structure- Several Operation performed on DS
Operations on Data Structure- Several Operation performed on DSOperations on Data Structure- Several Operation performed on DS
Operations on Data Structure- Several Operation performed on DS
Vaibhav Parjane
Classification of Data Structure -Linear and Non Linear
Classification of Data Structure -Linear and Non LinearClassification of Data Structure -Linear and Non Linear
Classification of Data Structure -Linear and Non Linear
Vaibhav Parjane
Need of Data Structure & Abstract Data Type
Need of Data Structure & Abstract Data TypeNeed of Data Structure & Abstract Data Type
Need of Data Structure & Abstract Data Type
Vaibhav Parjane
Introduction to data & Data Structure Definition
Introduction to data & Data Structure DefinitionIntroduction to data & Data Structure Definition
Introduction to data & Data Structure Definition
Vaibhav Parjane

Recently uploaded (20)

Knowledge-Based Agents in AI: Principles, Components, and Functionality
Knowledge-Based Agents in AI: Principles, Components, and FunctionalityKnowledge-Based Agents in AI: Principles, Components, and Functionality
Knowledge-Based Agents in AI: Principles, Components, and Functionality
Rashmi Bhat
Self-Compacting Concrete: Composition, Properties, and Applications in Modern...
Self-Compacting Concrete: Composition, Properties, and Applications in Modern...Self-Compacting Concrete: Composition, Properties, and Applications in Modern...
Self-Compacting Concrete: Composition, Properties, and Applications in Modern...
NIT SILCHAR
UHV UNIT-5 IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON ...
UHV UNIT-5    IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON ...UHV UNIT-5    IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON ...
UHV UNIT-5 IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON ...
ariomthermal2031
"Introduction to VLSI Design: Concepts and Applications"
"Introduction to VLSI Design: Concepts and Applications""Introduction to VLSI Design: Concepts and Applications"
"Introduction to VLSI Design: Concepts and Applications"
GtxDriver
Cloudera Partner Network Enablement Full.pdf
Cloudera Partner Network Enablement Full.pdfCloudera Partner Network Enablement Full.pdf
Cloudera Partner Network Enablement Full.pdf
Nguy畛n H畉i
Distributed renewable energy in Colombia.OECD2023.pdf
Distributed renewable energy in Colombia.OECD2023.pdfDistributed renewable energy in Colombia.OECD2023.pdf
Distributed renewable energy in Colombia.OECD2023.pdf
SantiagoCardonaGallo
Scalling Rails: The Journey to 200M Notifications
Scalling Rails: The Journey to 200M NotificationsScalling Rails: The Journey to 200M Notifications
Scalling Rails: The Journey to 200M Notifications
Gustavo Araujo
UHV UNIT-I INTRODUCTION TO VALUE EDUCATION .pptx
UHV UNIT-I INTRODUCTION TO VALUE EDUCATION  .pptxUHV UNIT-I INTRODUCTION TO VALUE EDUCATION  .pptx
UHV UNIT-I INTRODUCTION TO VALUE EDUCATION .pptx
ariomthermal2031
02.BigDataAnalytics curso de Legsi (1).pdf
02.BigDataAnalytics curso de Legsi (1).pdf02.BigDataAnalytics curso de Legsi (1).pdf
02.BigDataAnalytics curso de Legsi (1).pdf
ruioliveira1921
windrose1.ppt for seminar of civil .pptx
windrose1.ppt for seminar of civil .pptxwindrose1.ppt for seminar of civil .pptx
windrose1.ppt for seminar of civil .pptx
nukeshpandey5678
Shallow base metal exploration in northern New Brunswick.pdf
Shallow base metal exploration in northern New Brunswick.pdfShallow base metal exploration in northern New Brunswick.pdf
Shallow base metal exploration in northern New Brunswick.pdf
DUSABEMARIYA
Intro PPT SY_HONORS.pptx- Teaching scheme
Intro PPT SY_HONORS.pptx- Teaching schemeIntro PPT SY_HONORS.pptx- Teaching scheme
Intro PPT SY_HONORS.pptx- Teaching scheme
Priyanka Dange
Distillation Types & It's Applications 1-Mar-2025.pptx
Distillation Types & It's Applications 1-Mar-2025.pptxDistillation Types & It's Applications 1-Mar-2025.pptx
Distillation Types & It's Applications 1-Mar-2025.pptx
mrcr123
Virtual Power plants-Cleantech-Revolution
Virtual Power plants-Cleantech-RevolutionVirtual Power plants-Cleantech-Revolution
Virtual Power plants-Cleantech-Revolution
Ashoka Saket
Ppt engineering study material available
Ppt engineering study material availablePpt engineering study material available
Ppt engineering study material available
mhipplage
SIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHM
SIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHMSIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHM
SIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHM
VLSICS Design
Introduction to Forensic Research Digital Forensics
Introduction to Forensic Research Digital ForensicsIntroduction to Forensic Research Digital Forensics
Introduction to Forensic Research Digital Forensics
SaanviMisar
Artificial intelligence and Machine learning in remote sensing and GIS
Artificial intelligence  and Machine learning in remote sensing and GISArtificial intelligence  and Machine learning in remote sensing and GIS
Artificial intelligence and Machine learning in remote sensing and GIS
amirthamm2083
NFPA 70B & 70E Changes and Additions Webinar Presented By Fluke
NFPA 70B & 70E Changes and Additions Webinar Presented By FlukeNFPA 70B & 70E Changes and Additions Webinar Presented By Fluke
NFPA 70B & 70E Changes and Additions Webinar Presented By Fluke
Transcat
UHV UNIT-3 HARMONY IN THE FAMILY AND SOCIETY.pptx
UHV UNIT-3 HARMONY IN THE FAMILY AND SOCIETY.pptxUHV UNIT-3 HARMONY IN THE FAMILY AND SOCIETY.pptx
UHV UNIT-3 HARMONY IN THE FAMILY AND SOCIETY.pptx
ariomthermal2031
Knowledge-Based Agents in AI: Principles, Components, and Functionality
Knowledge-Based Agents in AI: Principles, Components, and FunctionalityKnowledge-Based Agents in AI: Principles, Components, and Functionality
Knowledge-Based Agents in AI: Principles, Components, and Functionality
Rashmi Bhat
Self-Compacting Concrete: Composition, Properties, and Applications in Modern...
Self-Compacting Concrete: Composition, Properties, and Applications in Modern...Self-Compacting Concrete: Composition, Properties, and Applications in Modern...
Self-Compacting Concrete: Composition, Properties, and Applications in Modern...
NIT SILCHAR
UHV UNIT-5 IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON ...
UHV UNIT-5    IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON ...UHV UNIT-5    IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON ...
UHV UNIT-5 IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON ...
ariomthermal2031
"Introduction to VLSI Design: Concepts and Applications"
"Introduction to VLSI Design: Concepts and Applications""Introduction to VLSI Design: Concepts and Applications"
"Introduction to VLSI Design: Concepts and Applications"
GtxDriver
Cloudera Partner Network Enablement Full.pdf
Cloudera Partner Network Enablement Full.pdfCloudera Partner Network Enablement Full.pdf
Cloudera Partner Network Enablement Full.pdf
Nguy畛n H畉i
Distributed renewable energy in Colombia.OECD2023.pdf
Distributed renewable energy in Colombia.OECD2023.pdfDistributed renewable energy in Colombia.OECD2023.pdf
Distributed renewable energy in Colombia.OECD2023.pdf
SantiagoCardonaGallo
Scalling Rails: The Journey to 200M Notifications
Scalling Rails: The Journey to 200M NotificationsScalling Rails: The Journey to 200M Notifications
Scalling Rails: The Journey to 200M Notifications
Gustavo Araujo
UHV UNIT-I INTRODUCTION TO VALUE EDUCATION .pptx
UHV UNIT-I INTRODUCTION TO VALUE EDUCATION  .pptxUHV UNIT-I INTRODUCTION TO VALUE EDUCATION  .pptx
UHV UNIT-I INTRODUCTION TO VALUE EDUCATION .pptx
ariomthermal2031
02.BigDataAnalytics curso de Legsi (1).pdf
02.BigDataAnalytics curso de Legsi (1).pdf02.BigDataAnalytics curso de Legsi (1).pdf
02.BigDataAnalytics curso de Legsi (1).pdf
ruioliveira1921
windrose1.ppt for seminar of civil .pptx
windrose1.ppt for seminar of civil .pptxwindrose1.ppt for seminar of civil .pptx
windrose1.ppt for seminar of civil .pptx
nukeshpandey5678
Shallow base metal exploration in northern New Brunswick.pdf
Shallow base metal exploration in northern New Brunswick.pdfShallow base metal exploration in northern New Brunswick.pdf
Shallow base metal exploration in northern New Brunswick.pdf
DUSABEMARIYA
Intro PPT SY_HONORS.pptx- Teaching scheme
Intro PPT SY_HONORS.pptx- Teaching schemeIntro PPT SY_HONORS.pptx- Teaching scheme
Intro PPT SY_HONORS.pptx- Teaching scheme
Priyanka Dange
Distillation Types & It's Applications 1-Mar-2025.pptx
Distillation Types & It's Applications 1-Mar-2025.pptxDistillation Types & It's Applications 1-Mar-2025.pptx
Distillation Types & It's Applications 1-Mar-2025.pptx
mrcr123
Virtual Power plants-Cleantech-Revolution
Virtual Power plants-Cleantech-RevolutionVirtual Power plants-Cleantech-Revolution
Virtual Power plants-Cleantech-Revolution
Ashoka Saket
Ppt engineering study material available
Ppt engineering study material availablePpt engineering study material available
Ppt engineering study material available
mhipplage
SIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHM
SIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHMSIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHM
SIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHM
VLSICS Design
Introduction to Forensic Research Digital Forensics
Introduction to Forensic Research Digital ForensicsIntroduction to Forensic Research Digital Forensics
Introduction to Forensic Research Digital Forensics
SaanviMisar
Artificial intelligence and Machine learning in remote sensing and GIS
Artificial intelligence  and Machine learning in remote sensing and GISArtificial intelligence  and Machine learning in remote sensing and GIS
Artificial intelligence and Machine learning in remote sensing and GIS
amirthamm2083
NFPA 70B & 70E Changes and Additions Webinar Presented By Fluke
NFPA 70B & 70E Changes and Additions Webinar Presented By FlukeNFPA 70B & 70E Changes and Additions Webinar Presented By Fluke
NFPA 70B & 70E Changes and Additions Webinar Presented By Fluke
Transcat
UHV UNIT-3 HARMONY IN THE FAMILY AND SOCIETY.pptx
UHV UNIT-3 HARMONY IN THE FAMILY AND SOCIETY.pptxUHV UNIT-3 HARMONY IN THE FAMILY AND SOCIETY.pptx
UHV UNIT-3 HARMONY IN THE FAMILY AND SOCIETY.pptx
ariomthermal2031

Unit No 2.pptx Basic s of C Programming

  • 1. Unit No-2 Basics of C Programming 2.1 Introduction to C. 2.2 Data Concepts. 2.3 Basic Input Output.
  • 2. 2.1 Introduction to C History of C. General Structure of C program. Header files. Main Function.
  • 3. History of C Language Developed at AT&Ts Bell Laboratories of USA in 1972 Designed and written by a man named Dennis Ritchie Most of its principles and ideas were taken from the earlier language B, BCPL and CPL Languages before C are PL/I, ALGOL, FORTRAN, Pascal, APL, B
  • 5. Importance of C General purpose language but normally used for system programming Robust due to rich set of built in functions and operaters for writing complex program C is highly portable i.e. platform independent Can add our own functions to C library
  • 6. Structure of C program. A 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
  • 7. Documentation Section The documentation section is the part of the program where the programmer gives the details associated with the program. He 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: om Sai date: 09/08/2021 */
  • 8. 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 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. float b; int a=7;
  • 9. 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. int main(void) { int a=10; printf(" %d", a); return 0; } Sub Program Section All the user-defined functions are defined in this section of the program. int add(int a, int b) { return a+b; }
  • 10. Header Files In C language, header files contain the set of predefined standard library functions. The #include preprocessing directive is used to include the header files with .h extension in the program. Here is the table that displays some of the header files in C language, Header Files Description 1. stdio.h Input/Output functions 2. conio.h Console Input/Output functions 3. stdlib.h General utility functions 4. math.h Mathematics functions 5. string.h String functions 6. ctype.h Character handling functions 7. time.h Date and time functions 8. float.h Limits of float types 9. limits.h Size of basic types 10.wctype.h Functions to determine the type contained in wide character data.
  • 11. 2.2 Data Concepts Character Set Tokens Keywords Identifires Variables Constants Datatypes C Operators Arithmetic Operators
  • 12. C CharacterSet A character denotes any alphabet, digit or special symbol used to represent information. Alphabets A,B,..,Y,Z a,b,,y,z Digits 0,1,2, 3,4,5,6, 7,8,9 Specialsymbols ~!@#%^&*()_-+=| {} [ ]:; "'<>,.?/
  • 13. Tokens Smallest individual units are known as C tokens. Six Types are 1. Keywords:- float, int, while 2. Identifiers: - name of variables and functions 3. Constants: -15.5, 10 4. Strings: - Abc, year 5. Special Symbols: - {}, @, 6. Operators: - +,-,*,/
  • 15. Keywords Keywords are the words whose meaning has already been explained to the C compiler. The following names are reserved by the C language. Their meaning is already defined, and they cannot be re- defined.
  • 16. Identifiers refer to the names of variables, functions and arrays, these are user- defined names Constants fixed values that do not change during the execution of a program. Variables is a data name that used to store a data value. Value stored in a variable may change during program execution. Data types The datatype determines what kinds of values a variable can store and what kind of operations can be performed on variables. Every variable used in a program must have a data type Two types of data types Primary and Secondary 1. Primary Data Types : - integer, float, character 2. Secondary Data Types :- array, pointer, structure
  • 18. C Operators 1. Arithmetic 2. Logical 3. Assignment 4. Relational 5. Increment And Decrement 6. Conditional 7. Bit Wise 8. Special Arithmetic Operators The basic operators for performing arithmetic: 9. + addition 10.- subtraction 11.* multiplication 12. / division 13.% modulus (remainder)
  • 19. Declaring Variable Variable Declaration Every variable in C must be declared before using it in program Variables are declared at the start of body of function of main function Declaration tells the compiler what the variable name is. It specifies what type of data value the variable will hold and what kind of operations can be performed on variables. The syntax is : - data_typename_of_variable E.g. int number, amount, balance; for declaring integer type variables E.g. float percent; for declaring float type variables E.g. char grade; for declaring char type variables Variable Initialization :- Means assigning an initial value to variable. E.g. int num = 1 ; // Variable Declaration and Initialization Declaring Variable as Constants (const):- E.g. const int class_size = 40; keeps value of variable constant throughout program
  • 20. 2.3 Basic Input Output. Input and Output Statements using printf() and scanf().
  • 21. printf( ) Printf() is used to print only messege or values of variables.General form of printf( ) function is, printf ( "format string", list of variables ) ; %f for printing real values %d for printing integer values %c for printing character values printf( ) can not only print values of variables, it can also print the result of an expression e.g. to print welcome messege the printf() statements is as follows. printf(Welcome to Sanjivani KBP Polytechnic);
  • 22. scanf() scanf( ) allows us to enter data from keyboard that will be formatted in a certain way. The general form of scanf( ) statement is as follows: scanf ( "format string", list of addresses of variables ) ; For example: scanf ( "%d ", &c ) ; Addresses of variables (addresses are obtained by using & the address of operator) is send to scanf( ) function. This is necessary because the values received from keyboard must be dropped into variables corresponding to these addresses. The values that are supplied through the keyboard must be separated by either blank(s), tab(s), or newline(s). The ampersand (&) before the variables in the scanf( ) function is a must. & is an Address of operator. It gives the location number used by the variable in memory. When we say &a, we are telling scanf( ) at which memory location should it store the value supplied by the user from the keyboard.