SlideShare a Scribd company logo
Introduction to c programming
 Program is a collection of instructions that
will perform some task.
 Source code of a Hello World
program written in the C programming
language
#include <stdio.h>
int main(void)
{
printf("Hello world!n");
return 0;
}
 C was developed by Dennis Ritchie at Bell
laboratory in 1972
 It is an upgraded version of languages B and
BCPL.
 It is a structured programming language.
 It is highly portable.
 It is a middle level language.
 It is a case sensitive language.
 It uses Top-Down approach.
 It is a Free form language.etc,.
GLOBAL DECLARATION SECTION
DOCUMENTATION SECTION
PREPROCESSOR SECTION
DEFINITION SECTION
main()
{
Declaration part;
Executable Part;
}
sub program section
{
Body of the subprogram;
}
 Enter the program in a C editor.
 Save the program (File  Save) or F2. Use
the extension .c for saving the file.
Eg: sample.c
 Compile the program(Compile  Compile)
or Alt+F9.
 Run the program(Run  Run) or Ctrl+F9.
 Enter the program in vi editor.
 Save the file using :wq
Use the extension .c for saving the file.
Eg: sample.c
 Compile the program.
Eg: cc sample.c (or) gcc sample.c
 Run the program using a.out.
 Identifiers are names given to various
program elements such as functions and
arrays etc,.
› Example:
int total,marks;
› Here total and marks are user defined
identifiers.
 First character must be alphabetic or underscore.
 Must consist only of alphabetic characters, digits, or
underscores.
 Only the first 31 characters of an identifier are
significant and are recognized by the compiler.
 Cannot use a keywords or reserved word (e.g. main,
include, printf & scanf etc.).
 No space are allowed between the identifiers etc,.
 C is case sensitive, e.g. My_name  my_name.
Valid Names Invalid Names
a a1 $sum /* $ is illegal */
student_name stdntNm 2names /* Starts with 2 */
_aSystemName _anthrSysNm stdnt Nmbr /* no spaces */
TRUE FALSE int /* reserved word */
Variables :
Variable is an identifier that is used to represent some
specified type of information.
Eg: x=3 Here x is variable.
auto register continue
double typedef for
int char signed
struct extern void
break return default
else union goto
long const sizeof
switch float do
case short if
enum unsigned
static while
It is a reserved word, which cannot be used for
anything else. Examples:
Constants
Character Constants
Numeric Constants
Real
Constant
Integer
Constant
String
Constant
Single
Character
Constant
Constants
Numeric Constants
Integer
Constant
Constants
Numeric Constants
Real
Constant
Integer
Constant
Constants
Numeric Constants
Single
Character
Constant
Real
Constant
Integer
Constant
Constants
Numeric Constants
String
Constant
Single
Character
Constant
Real
Constant
Integer
Constant
Constants
Numeric Constants
Constants
Numeric Constants Character Constants
Numeric Constants
It is an entity whose value does not changes during
the execution.
Integer constants
 It is formed using a sequence of digits.
Decimal - 0 to 9 .
Octal - 0 to 7.
Hexa - 0 to 9 ,A to F
Eg: 10,75 etc.
Rules for defining Integer Constant:
 It must have at least one digit.
 Decimal point are not allowed.
 No blank space or commas are allowed.
 It can be either positive or negative. Etc,.
Real constants
 It is formed using a sequence of digits but it
contain decimal point.
 length, height, price distance measured in
real number.
Eg: 2.5, 5.11, etc.
Single character constant
A character constant is a single character they
also represented with single digit or a single
special symbol which is enclosed in single quotes.
Eg: ‘a’, ‘8’,’_’etc.
String constants
 String constant are sequence of characters
enclosed with in double quote.
Eg: “Hello” ,”444”,”a” etc,.
Data Types
A data type is a classification identifying one of various
types of data, such as real-valued, integer or Boolean,
that determines the possible values for that type
 A number without a fraction part : integral number.
 Integer occupies 2 Bytes.
 The Control or Format String for integer is %d.
 C supports three different sizes of the integer
data type :
 short int
 int
 long int
 A floating-point type is a number with a
fractional part, e.g. 56.78.
 Floating point numbers occupies 4 Bytes.
 The Control or Format String for float is %f.
 C supports three different sizes of the float data
type
 Double
 float
 long double
 Character are generally stored using 8 bits(1 Byte)
of the internal storage.
 The Control or Format String for Character is %c.
Character ASCII code value
a 97(decimal) or 01100001(binary)
x 120(decimal) or 01111000(binary)
 The void type has no values and no operations.
 Both the set of values and the set of operations
are empty.
Data type Size(bytes) Range Format string
(or)Control String
Char 1 128 to 127 %c
Unsigned char 1 0 to 255 %c
Short or int 2 -32,768 to 32,767 %i or %d
Unsigned int 2 0 to 65535 %u
Long 4 -2147483648 to 2147483647 %ld
Unsigned long 4 0 to 4294967295 %lu
Float 4 3.4 e-38 to 3.4 e+38 %f or %g
Double 8 1.7 e-308 to 1.7 e+308 %lf
Long Double 10 3.4 e-4932 to 1.1 e+4932 %lf
 To create a variable, you must specify
the type.
Example: float price;
int a,b;
char code;
Ad

More Related Content

What's hot (20)

Programming construction tools
Programming construction toolsProgramming construction tools
Programming construction tools
sunilchute1
 
pointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handlingpointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handling
Rai University
 
C++ lecture 01
C++   lecture 01C++   lecture 01
C++ lecture 01
HNDE Labuduwa Galle
 
Zaridah lecture2
Zaridah lecture2Zaridah lecture2
Zaridah lecture2
Aziz Sahat
 
Constant, variables, data types
Constant, variables, data typesConstant, variables, data types
Constant, variables, data types
Pratik Devmurari
 
Cpu-fundamental of C
Cpu-fundamental of CCpu-fundamental of C
Cpu-fundamental of C
Suchit Patel
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
programming9
 
C material
C materialC material
C material
tarique472
 
Variables and data types in C++
Variables and data types in C++Variables and data types in C++
Variables and data types in C++
Ameer Khan
 
Constant and variacles in c
Constant   and variacles in cConstant   and variacles in c
Constant and variacles in c
yash patel
 
Constants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya JyothiConstants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya Jyothi
SowmyaJyothi3
 
FUNDAMENTAL OF C
FUNDAMENTAL OF CFUNDAMENTAL OF C
FUNDAMENTAL OF C
KRUNAL RAVAL
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programming
avikdhupar
 
constants, variables and datatypes in C
constants, variables and datatypes in Cconstants, variables and datatypes in C
constants, variables and datatypes in C
Sahithi Naraparaju
 
What is identifier c programming
What is identifier c programmingWhat is identifier c programming
What is identifier c programming
Rumman Ansari
 
C tokens
C tokensC tokens
C tokens
Manu1325
 
Data type in c
Data type in cData type in c
Data type in c
thirumalaikumar3
 
Basic C Programming language
Basic C Programming languageBasic C Programming language
Basic C Programming language
Abhishek Soni
 
Introduction to Basic C programming 01
Introduction to Basic C programming 01Introduction to Basic C programming 01
Introduction to Basic C programming 01
Wingston
 
Datatype in c++ unit 3 -topic 2
Datatype in c++ unit 3 -topic 2Datatype in c++ unit 3 -topic 2
Datatype in c++ unit 3 -topic 2
MOHIT TOMAR
 
Programming construction tools
Programming construction toolsProgramming construction tools
Programming construction tools
sunilchute1
 
pointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handlingpointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handling
Rai University
 
Zaridah lecture2
Zaridah lecture2Zaridah lecture2
Zaridah lecture2
Aziz Sahat
 
Constant, variables, data types
Constant, variables, data typesConstant, variables, data types
Constant, variables, data types
Pratik Devmurari
 
Cpu-fundamental of C
Cpu-fundamental of CCpu-fundamental of C
Cpu-fundamental of C
Suchit Patel
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
programming9
 
Variables and data types in C++
Variables and data types in C++Variables and data types in C++
Variables and data types in C++
Ameer Khan
 
Constant and variacles in c
Constant   and variacles in cConstant   and variacles in c
Constant and variacles in c
yash patel
 
Constants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya JyothiConstants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya Jyothi
SowmyaJyothi3
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programming
avikdhupar
 
constants, variables and datatypes in C
constants, variables and datatypes in Cconstants, variables and datatypes in C
constants, variables and datatypes in C
Sahithi Naraparaju
 
What is identifier c programming
What is identifier c programmingWhat is identifier c programming
What is identifier c programming
Rumman Ansari
 
Basic C Programming language
Basic C Programming languageBasic C Programming language
Basic C Programming language
Abhishek Soni
 
Introduction to Basic C programming 01
Introduction to Basic C programming 01Introduction to Basic C programming 01
Introduction to Basic C programming 01
Wingston
 
Datatype in c++ unit 3 -topic 2
Datatype in c++ unit 3 -topic 2Datatype in c++ unit 3 -topic 2
Datatype in c++ unit 3 -topic 2
MOHIT TOMAR
 

Similar to Introduction to c programming (20)

C the basic concepts
C the basic conceptsC the basic concepts
C the basic concepts
Abhinav Vatsa
 
PPS_unit_2_gtu_sem_2_year_2023_GTUU.pptx
PPS_unit_2_gtu_sem_2_year_2023_GTUU.pptxPPS_unit_2_gtu_sem_2_year_2023_GTUU.pptx
PPS_unit_2_gtu_sem_2_year_2023_GTUU.pptx
ZwecklosSe
 
Diploma ii cfpc u-2 datatypes and variables in c language
Diploma ii  cfpc u-2 datatypes and variables in c languageDiploma ii  cfpc u-2 datatypes and variables in c language
Diploma ii cfpc u-2 datatypes and variables in c language
Rai University
 
C language
C language C language
C language
COMSATS Institute of Information Technology
 
Bsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c languageBsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c language
Rai University
 
Lecture 01 2017
Lecture 01 2017Lecture 01 2017
Lecture 01 2017
Jesmin Akhter
 
Btech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c languageBtech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c language
Rai University
 
Mca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c languageMca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c language
Rai University
 
c_pro_introduction.pptx
c_pro_introduction.pptxc_pro_introduction.pptx
c_pro_introduction.pptx
RohitRaj744272
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
MOHAMAD NOH AHMAD
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 Foc
JAYA
 
All C ppt.ppt
All C ppt.pptAll C ppt.ppt
All C ppt.ppt
JeelBhanderi4
 
c programming session 1.pptx
c programming session 1.pptxc programming session 1.pptx
c programming session 1.pptx
RSathyaPriyaCSEKIOT
 
Introduction%20C.pptx
Introduction%20C.pptxIntroduction%20C.pptx
Introduction%20C.pptx
20EUEE018DEEPAKM
 
CONSTANTS, VARIABLES & DATATYPES IN C
CONSTANTS, VARIABLES & DATATYPES IN CCONSTANTS, VARIABLES & DATATYPES IN C
CONSTANTS, VARIABLES & DATATYPES IN C
Sahithi Naraparaju
 
LESSON1-C_programming (1).GRADE 8 LESSONpptx
LESSON1-C_programming (1).GRADE 8 LESSONpptxLESSON1-C_programming (1).GRADE 8 LESSONpptx
LESSON1-C_programming (1).GRADE 8 LESSONpptx
joachimbenedicttulau
 
C PROGRAMMING LANGUAGE.pptx
 C PROGRAMMING LANGUAGE.pptx C PROGRAMMING LANGUAGE.pptx
C PROGRAMMING LANGUAGE.pptx
AnshSrivastava48
 
CHAPTER 3 STRUCTURED PROGRAMMING.pptx 2024
CHAPTER 3 STRUCTURED PROGRAMMING.pptx 2024CHAPTER 3 STRUCTURED PROGRAMMING.pptx 2024
CHAPTER 3 STRUCTURED PROGRAMMING.pptx 2024
ALPHONCEKIMUYU
 
Introduction to C Programming language Chapter02.pptx
Introduction to C Programming language Chapter02.pptxIntroduction to C Programming language Chapter02.pptx
Introduction to C Programming language Chapter02.pptx
foxel54542
 
Chapter02.PPTArray.pptxArray.pptxArray.pptx
Chapter02.PPTArray.pptxArray.pptxArray.pptxChapter02.PPTArray.pptxArray.pptxArray.pptx
Chapter02.PPTArray.pptxArray.pptxArray.pptx
yatakumar84
 
C the basic concepts
C the basic conceptsC the basic concepts
C the basic concepts
Abhinav Vatsa
 
PPS_unit_2_gtu_sem_2_year_2023_GTUU.pptx
PPS_unit_2_gtu_sem_2_year_2023_GTUU.pptxPPS_unit_2_gtu_sem_2_year_2023_GTUU.pptx
PPS_unit_2_gtu_sem_2_year_2023_GTUU.pptx
ZwecklosSe
 
Diploma ii cfpc u-2 datatypes and variables in c language
Diploma ii  cfpc u-2 datatypes and variables in c languageDiploma ii  cfpc u-2 datatypes and variables in c language
Diploma ii cfpc u-2 datatypes and variables in c language
Rai University
 
Bsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c languageBsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c language
Rai University
 
Btech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c languageBtech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c language
Rai University
 
Mca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c languageMca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c language
Rai University
 
c_pro_introduction.pptx
c_pro_introduction.pptxc_pro_introduction.pptx
c_pro_introduction.pptx
RohitRaj744272
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
MOHAMAD NOH AHMAD
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 Foc
JAYA
 
CONSTANTS, VARIABLES & DATATYPES IN C
CONSTANTS, VARIABLES & DATATYPES IN CCONSTANTS, VARIABLES & DATATYPES IN C
CONSTANTS, VARIABLES & DATATYPES IN C
Sahithi Naraparaju
 
LESSON1-C_programming (1).GRADE 8 LESSONpptx
LESSON1-C_programming (1).GRADE 8 LESSONpptxLESSON1-C_programming (1).GRADE 8 LESSONpptx
LESSON1-C_programming (1).GRADE 8 LESSONpptx
joachimbenedicttulau
 
C PROGRAMMING LANGUAGE.pptx
 C PROGRAMMING LANGUAGE.pptx C PROGRAMMING LANGUAGE.pptx
C PROGRAMMING LANGUAGE.pptx
AnshSrivastava48
 
CHAPTER 3 STRUCTURED PROGRAMMING.pptx 2024
CHAPTER 3 STRUCTURED PROGRAMMING.pptx 2024CHAPTER 3 STRUCTURED PROGRAMMING.pptx 2024
CHAPTER 3 STRUCTURED PROGRAMMING.pptx 2024
ALPHONCEKIMUYU
 
Introduction to C Programming language Chapter02.pptx
Introduction to C Programming language Chapter02.pptxIntroduction to C Programming language Chapter02.pptx
Introduction to C Programming language Chapter02.pptx
foxel54542
 
Chapter02.PPTArray.pptxArray.pptxArray.pptx
Chapter02.PPTArray.pptxArray.pptxArray.pptxChapter02.PPTArray.pptxArray.pptxArray.pptx
Chapter02.PPTArray.pptxArray.pptxArray.pptx
yatakumar84
 
Ad

Recently uploaded (20)

MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFAMCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
LDMMIA 2024 Crystal Gold Lecture 1 Bonus
LDMMIA 2024 Crystal Gold Lecture 1 BonusLDMMIA 2024 Crystal Gold Lecture 1 Bonus
LDMMIA 2024 Crystal Gold Lecture 1 Bonus
LDM & Mia eStudios
 
EUPHORIA GENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
EUPHORIA GENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025EUPHORIA GENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
EUPHORIA GENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
Quiz Club of PSG College of Arts & Science
 
PUBH1000 Slides - Module 10: Health Promotion
PUBH1000 Slides - Module 10: Health PromotionPUBH1000 Slides - Module 10: Health Promotion
PUBH1000 Slides - Module 10: Health Promotion
JonathanHallett4
 
The role of wall art in interior designing
The role of wall art in interior designingThe role of wall art in interior designing
The role of wall art in interior designing
meghaark2110
 
How to Add Button in Chatter in Odoo 18 - Odoo Slides
How to Add Button in Chatter in Odoo 18 - Odoo SlidesHow to Add Button in Chatter in Odoo 18 - Odoo Slides
How to Add Button in Chatter in Odoo 18 - Odoo Slides
Celine George
 
Module_2_Types_and_Approaches_of_Research (2).pptx
Module_2_Types_and_Approaches_of_Research (2).pptxModule_2_Types_and_Approaches_of_Research (2).pptx
Module_2_Types_and_Approaches_of_Research (2).pptx
drroxannekemp
 
Statement by Linda McMahon on May 21, 2025
Statement by Linda McMahon on May 21, 2025Statement by Linda McMahon on May 21, 2025
Statement by Linda McMahon on May 21, 2025
Mebane Rash
 
20250515 Ntegra San Francisco 20250515 v15.pptx
20250515 Ntegra San Francisco 20250515 v15.pptx20250515 Ntegra San Francisco 20250515 v15.pptx
20250515 Ntegra San Francisco 20250515 v15.pptx
home
 
Launch of The State of Global Teenage Career Preparation - Andreas Schleicher...
Launch of The State of Global Teenage Career Preparation - Andreas Schleicher...Launch of The State of Global Teenage Career Preparation - Andreas Schleicher...
Launch of The State of Global Teenage Career Preparation - Andreas Schleicher...
EduSkills OECD
 
Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...
parmarjuli1412
 
MICROBIAL GENETICS -tranformation and tranduction.pdf
MICROBIAL GENETICS -tranformation and tranduction.pdfMICROBIAL GENETICS -tranformation and tranduction.pdf
MICROBIAL GENETICS -tranformation and tranduction.pdf
DHARMENDRA SAHU
 
114P_English.pdf114P_English.pdf114P_English.pdf
114P_English.pdf114P_English.pdf114P_English.pdf114P_English.pdf114P_English.pdf114P_English.pdf
114P_English.pdf114P_English.pdf114P_English.pdf
paulinelee52
 
How to Manage Manual Reordering Rule in Odoo 18 Inventory
How to Manage Manual Reordering Rule in Odoo 18 InventoryHow to Manage Manual Reordering Rule in Odoo 18 Inventory
How to Manage Manual Reordering Rule in Odoo 18 Inventory
Celine George
 
PUBH1000 Slides - Module 12: Advocacy for Health
PUBH1000 Slides - Module 12: Advocacy for HealthPUBH1000 Slides - Module 12: Advocacy for Health
PUBH1000 Slides - Module 12: Advocacy for Health
JonathanHallett4
 
Final Evaluation.docx...........................
Final Evaluation.docx...........................Final Evaluation.docx...........................
Final Evaluation.docx...........................
l1bbyburrell
 
GENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 4 MARCH 2025 .pdf
GENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 4 MARCH 2025 .pdfGENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 4 MARCH 2025 .pdf
GENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 4 MARCH 2025 .pdf
Quiz Club of PSG College of Arts & Science
 
IMPACT_OF_SOCIAL-MEDIA- AMONG- TEENAGERS
IMPACT_OF_SOCIAL-MEDIA- AMONG- TEENAGERSIMPACT_OF_SOCIAL-MEDIA- AMONG- TEENAGERS
IMPACT_OF_SOCIAL-MEDIA- AMONG- TEENAGERS
rajaselviazhagiri1
 
The History of Kashmir Lohar Dynasty NEP.ppt
The History of Kashmir Lohar Dynasty NEP.pptThe History of Kashmir Lohar Dynasty NEP.ppt
The History of Kashmir Lohar Dynasty NEP.ppt
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Module 1: Foundations of Research
Module 1: Foundations of ResearchModule 1: Foundations of Research
Module 1: Foundations of Research
drroxannekemp
 
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFAMCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
LDMMIA 2024 Crystal Gold Lecture 1 Bonus
LDMMIA 2024 Crystal Gold Lecture 1 BonusLDMMIA 2024 Crystal Gold Lecture 1 Bonus
LDMMIA 2024 Crystal Gold Lecture 1 Bonus
LDM & Mia eStudios
 
PUBH1000 Slides - Module 10: Health Promotion
PUBH1000 Slides - Module 10: Health PromotionPUBH1000 Slides - Module 10: Health Promotion
PUBH1000 Slides - Module 10: Health Promotion
JonathanHallett4
 
The role of wall art in interior designing
The role of wall art in interior designingThe role of wall art in interior designing
The role of wall art in interior designing
meghaark2110
 
How to Add Button in Chatter in Odoo 18 - Odoo Slides
How to Add Button in Chatter in Odoo 18 - Odoo SlidesHow to Add Button in Chatter in Odoo 18 - Odoo Slides
How to Add Button in Chatter in Odoo 18 - Odoo Slides
Celine George
 
Module_2_Types_and_Approaches_of_Research (2).pptx
Module_2_Types_and_Approaches_of_Research (2).pptxModule_2_Types_and_Approaches_of_Research (2).pptx
Module_2_Types_and_Approaches_of_Research (2).pptx
drroxannekemp
 
Statement by Linda McMahon on May 21, 2025
Statement by Linda McMahon on May 21, 2025Statement by Linda McMahon on May 21, 2025
Statement by Linda McMahon on May 21, 2025
Mebane Rash
 
20250515 Ntegra San Francisco 20250515 v15.pptx
20250515 Ntegra San Francisco 20250515 v15.pptx20250515 Ntegra San Francisco 20250515 v15.pptx
20250515 Ntegra San Francisco 20250515 v15.pptx
home
 
Launch of The State of Global Teenage Career Preparation - Andreas Schleicher...
Launch of The State of Global Teenage Career Preparation - Andreas Schleicher...Launch of The State of Global Teenage Career Preparation - Andreas Schleicher...
Launch of The State of Global Teenage Career Preparation - Andreas Schleicher...
EduSkills OECD
 
Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...
parmarjuli1412
 
MICROBIAL GENETICS -tranformation and tranduction.pdf
MICROBIAL GENETICS -tranformation and tranduction.pdfMICROBIAL GENETICS -tranformation and tranduction.pdf
MICROBIAL GENETICS -tranformation and tranduction.pdf
DHARMENDRA SAHU
 
114P_English.pdf114P_English.pdf114P_English.pdf
114P_English.pdf114P_English.pdf114P_English.pdf114P_English.pdf114P_English.pdf114P_English.pdf
114P_English.pdf114P_English.pdf114P_English.pdf
paulinelee52
 
How to Manage Manual Reordering Rule in Odoo 18 Inventory
How to Manage Manual Reordering Rule in Odoo 18 InventoryHow to Manage Manual Reordering Rule in Odoo 18 Inventory
How to Manage Manual Reordering Rule in Odoo 18 Inventory
Celine George
 
PUBH1000 Slides - Module 12: Advocacy for Health
PUBH1000 Slides - Module 12: Advocacy for HealthPUBH1000 Slides - Module 12: Advocacy for Health
PUBH1000 Slides - Module 12: Advocacy for Health
JonathanHallett4
 
Final Evaluation.docx...........................
Final Evaluation.docx...........................Final Evaluation.docx...........................
Final Evaluation.docx...........................
l1bbyburrell
 
IMPACT_OF_SOCIAL-MEDIA- AMONG- TEENAGERS
IMPACT_OF_SOCIAL-MEDIA- AMONG- TEENAGERSIMPACT_OF_SOCIAL-MEDIA- AMONG- TEENAGERS
IMPACT_OF_SOCIAL-MEDIA- AMONG- TEENAGERS
rajaselviazhagiri1
 
Module 1: Foundations of Research
Module 1: Foundations of ResearchModule 1: Foundations of Research
Module 1: Foundations of Research
drroxannekemp
 
Ad

Introduction to c programming

  • 2.  Program is a collection of instructions that will perform some task.  Source code of a Hello World program written in the C programming language #include <stdio.h> int main(void) { printf("Hello world!n"); return 0; }
  • 3.  C was developed by Dennis Ritchie at Bell laboratory in 1972  It is an upgraded version of languages B and BCPL.
  • 4.  It is a structured programming language.  It is highly portable.  It is a middle level language.  It is a case sensitive language.  It uses Top-Down approach.  It is a Free form language.etc,.
  • 5. GLOBAL DECLARATION SECTION DOCUMENTATION SECTION PREPROCESSOR SECTION DEFINITION SECTION main() { Declaration part; Executable Part; } sub program section { Body of the subprogram; }
  • 6.  Enter the program in a C editor.  Save the program (File  Save) or F2. Use the extension .c for saving the file. Eg: sample.c  Compile the program(Compile  Compile) or Alt+F9.  Run the program(Run  Run) or Ctrl+F9.
  • 7.  Enter the program in vi editor.  Save the file using :wq Use the extension .c for saving the file. Eg: sample.c  Compile the program. Eg: cc sample.c (or) gcc sample.c  Run the program using a.out.
  • 8.  Identifiers are names given to various program elements such as functions and arrays etc,. › Example: int total,marks; › Here total and marks are user defined identifiers.
  • 9.  First character must be alphabetic or underscore.  Must consist only of alphabetic characters, digits, or underscores.  Only the first 31 characters of an identifier are significant and are recognized by the compiler.  Cannot use a keywords or reserved word (e.g. main, include, printf & scanf etc.).  No space are allowed between the identifiers etc,.  C is case sensitive, e.g. My_name  my_name.
  • 10. Valid Names Invalid Names a a1 $sum /* $ is illegal */ student_name stdntNm 2names /* Starts with 2 */ _aSystemName _anthrSysNm stdnt Nmbr /* no spaces */ TRUE FALSE int /* reserved word */ Variables : Variable is an identifier that is used to represent some specified type of information. Eg: x=3 Here x is variable.
  • 11. auto register continue double typedef for int char signed struct extern void break return default else union goto long const sizeof switch float do case short if enum unsigned static while It is a reserved word, which cannot be used for anything else. Examples:
  • 12. Constants Character Constants Numeric Constants Real Constant Integer Constant String Constant Single Character Constant Constants Numeric Constants Integer Constant Constants Numeric Constants Real Constant Integer Constant Constants Numeric Constants Single Character Constant Real Constant Integer Constant Constants Numeric Constants String Constant Single Character Constant Real Constant Integer Constant Constants Numeric Constants Constants Numeric Constants Character Constants Numeric Constants It is an entity whose value does not changes during the execution.
  • 13. Integer constants  It is formed using a sequence of digits. Decimal - 0 to 9 . Octal - 0 to 7. Hexa - 0 to 9 ,A to F Eg: 10,75 etc. Rules for defining Integer Constant:  It must have at least one digit.  Decimal point are not allowed.  No blank space or commas are allowed.  It can be either positive or negative. Etc,.
  • 14. Real constants  It is formed using a sequence of digits but it contain decimal point.  length, height, price distance measured in real number. Eg: 2.5, 5.11, etc.
  • 15. Single character constant A character constant is a single character they also represented with single digit or a single special symbol which is enclosed in single quotes. Eg: ‘a’, ‘8’,’_’etc. String constants  String constant are sequence of characters enclosed with in double quote. Eg: “Hello” ,”444”,”a” etc,.
  • 16. Data Types A data type is a classification identifying one of various types of data, such as real-valued, integer or Boolean, that determines the possible values for that type
  • 17.  A number without a fraction part : integral number.  Integer occupies 2 Bytes.  The Control or Format String for integer is %d.  C supports three different sizes of the integer data type :  short int  int  long int
  • 18.  A floating-point type is a number with a fractional part, e.g. 56.78.  Floating point numbers occupies 4 Bytes.  The Control or Format String for float is %f.  C supports three different sizes of the float data type  Double  float  long double
  • 19.  Character are generally stored using 8 bits(1 Byte) of the internal storage.  The Control or Format String for Character is %c. Character ASCII code value a 97(decimal) or 01100001(binary) x 120(decimal) or 01111000(binary)
  • 20.  The void type has no values and no operations.  Both the set of values and the set of operations are empty.
  • 21. Data type Size(bytes) Range Format string (or)Control String Char 1 128 to 127 %c Unsigned char 1 0 to 255 %c Short or int 2 -32,768 to 32,767 %i or %d Unsigned int 2 0 to 65535 %u Long 4 -2147483648 to 2147483647 %ld Unsigned long 4 0 to 4294967295 %lu Float 4 3.4 e-38 to 3.4 e+38 %f or %g Double 8 1.7 e-308 to 1.7 e+308 %lf Long Double 10 3.4 e-4932 to 1.1 e+4932 %lf
  • 22.  To create a variable, you must specify the type. Example: float price; int a,b; char code;