SlideShare a Scribd company logo
Survey of Programming Languages
Introduction to C-Language
Lecture 2
Levels of Programming Languages
There are 3 levels of programming languages
i) High-Level Language
ii) Middle-Level Language
iii) Low-Level Language
A First Program (C )
#include <stdio.h>
int main(void)
{
printf("This is my first C program.n");
return(0);
}
statements
header
open and close braces mark
the beginning and end
makes input
and output available
to us
A First Program – What Does It
Do?
printf("This is my first C program.n");
return(0);
Prints the message
This is my first C program.
Ends the program Ends the line
White Space Characters
•The character that produces blank space
when printed is called a white space
character, e.g.
•Spaces
•Tabs
•New Lines
Constants & Variables
•Constants
•1,56,1.89,’a’,’Z’,”BSCS”
•Variables
X=5,
X=20
Data types and Sizes
•There are three main data types in
C/C++
i) Character char
ii) Integer int
iii) Floating Point float
Character data type
• Represented by char
• used for storing a character, digit or
special character.
• A character constant must be enclosed in
single quotations i.e. ‘A’, ‘1’ or ‘*’ etc.
• uses/occupies one byte( 8 bits) of
memory.
• character constant can be signed or
unsigned.
Character data type
•There are 3 types of character data type, i.e. char,
signed char and unsigned char. e.g.
•char age means signed char
•signed char code means signed char
•unsigned char value means unsigned char
•The value range of binary numbers in:
•Char -128 to 127 or 0 to 255
•signed char is from -128 to +127
•unsigned char is from 0 to 255
Integer data type
•Integer data type is represented by int
•used for storing Integers, i.e. numeric values
without decimal portions.
•RANGE: Store a value ranging from -32,768 to
+ 32,767
•MEMORY: 2 bytes of memory
•Integer data type is also represented as
•Short
•long
Integer data types
int 2 or 4 bytes
-32,768 to
32,767 or -
2,147,483,648
to
2,147,483,647
short 2 bytes
-32,768 to
32,767
long 4 bytes
-2,147,483,648
to
2,147,483,647
Type Storage size Value Range
Integer data type
•Another int type is signed int which is used to
store sign too along with the numeric value.
•Another int type is unsigned int which is used
to store values without sign
•So, there are 9 types of Integer data types, i.e.
int, short, signed int, unsigned int, signed
short, unsigned short, long, signed long and
unsigned long e.g.
Type Storage size Value range
char 1 byte
-128 to 127 or 0 to
255
unsigned char 1 byte 0 to 255
signed char 1 byte -128 to 127
int 2 or 4 bytes
-32,768 to 32,767 or
-2,147,483,648 to
2,147,483,647
unsigned int 2 or 4 bytes
0 to 65,535 or 0 to
4,294,967,295
short 2 bytes -32,768 to 32,767
unsigned short 2 bytes 0 to 65,535
long 4 bytes
-2,147,483,648 to
2,147,483,647
unsigned long 4 bytes 0 to 4,294,967,295
Examples
•int a; means signed int
•signed int b; means signed int
•unsigned int c; means unsigned int
•short d; means signed short
•signed short e; means signed short
•unsigned short f; means unsigned short
•long g; means signed long
•signed long h; means signed long
•unsigned long I; means unsigned long
Float data type
•Float data type is represented by float and is used for
storing numeric values
•Means fraction or decimal portion.
•Float data type takes 4 bytes of memory.
• A floating point number is expressed in scientific
notation.
•The reason of storing float values in scientific notation
is that they can be very large or extremely small.
Float data type
•2000000000000000 = 2e+15
•0.00000000000023 = 2.3e-13
•A value written as 47e3 means 47 x 10^3
•Exponent value ranges from -38 to +38, i.e. 47x10^-
38 to 47x10^+38
•Another float type is double that takes 8 bytes of
memory.
•Exponent values in double ranges from -308 to + 308,
i.e. 47x10-308 to 47x10+308
Data types
Name Description Size* Range*
char Character or small integer. 1byte
signed: -128 to 127
unsigned: 0 to 255
short int
(short) Short Integer. 2bytes
signed: -32768 to 32767
unsigned: 0 to 65535
int Integer. 2bytes
signed: -32768 to 32767
unsigned: 0 to 65535
long int
(long) Long integer. 4bytes
signed: -2147483648 to 2147483647
unsigned: 0 to 4294967295
bool
Boolean value. It can take
one of two values: true or
false. 1byte true or false
float Floating point number. 4bytes +/- 3.4e +/- 38 (~7 digits)
double
Double precision floating
point number. 8bytes +/- 1.7e +/- 308 (~15 digits)
long double
Long double precision
floating point number. 8bytes +/- 1.7e +/- 308 (~15 digits)
Practice
• char myGrade = 'B';
• char a = 65, b = 66, c = 67;
• string greeting = "Hello";
• float f1 = 35e3;
• double d1 = 12E4;
• bool isCodingFun = true;
• bool isFishTasty = false;

More Related Content

Similar to Lecture 2 introduction to Programming languages C.pptx (20)

Constant, variables, data types
Constant, variables, data typesConstant, variables, data types
Constant, variables, data types
Pratik Devmurari
 
C language (Collected By Dushmanta)
C language  (Collected By Dushmanta)C language  (Collected By Dushmanta)
C language (Collected By Dushmanta)
Dushmanta Nath
 
C programming session 01
C programming session 01C programming session 01
C programming session 01
AjayBahoriya
 
Datatypes
DatatypesDatatypes
Datatypes
ZTE Nepal
 
2 1. variables & data types
2 1. variables & data types2 1. variables & data types
2 1. variables & data types
웅식 전
 
Data types slides by Faixan
Data types slides by FaixanData types slides by Faixan
Data types slides by Faixan
ٖFaiXy :)
 
Data Type in C Programming
Data Type in C ProgrammingData Type in C Programming
Data Type in C Programming
Qazi Shahzad Ali
 
Data types in c++
Data types in c++ Data types in c++
Data types in c++
RushikeshGaikwad28
 
A Closer Look at Data Types, Variables and Expressions
A Closer Look at Data Types, Variables and ExpressionsA Closer Look at Data Types, Variables and Expressions
A Closer Look at Data Types, Variables and Expressions
Inan Mashrur
 
Vcs14
Vcs14Vcs14
Vcs14
Malikireddy Bramhananda Reddy
 
2. Variables and Data Types in C++ proramming.pptx
2. Variables and Data Types in C++ proramming.pptx2. Variables and Data Types in C++ proramming.pptx
2. Variables and Data Types in C++ proramming.pptx
Ahmad177077
 
C Programming Assignment
C Programming AssignmentC Programming Assignment
C Programming Assignment
Vijayananda Mohire
 
C language
C languageC language
C language
Mukul Kirti Verma
 
Data types
Data typesData types
Data types
Nokesh Prabhakar
 
Data Types in C
Data Types in CData Types in C
Data Types in C
yarkhosh
 
C language Unit 2 Slides, UPTU C language
C language Unit 2 Slides, UPTU C languageC language Unit 2 Slides, UPTU C language
C language Unit 2 Slides, UPTU C language
Anurag University Hyderabad
 
Ch7 Basic Types
Ch7 Basic TypesCh7 Basic Types
Ch7 Basic Types
SzeChingChen
 
FP 201 Unit 2 - Part 2
FP 201 Unit 2 - Part 2FP 201 Unit 2 - Part 2
FP 201 Unit 2 - Part 2
rohassanie
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
marvellous2
 
Structured Programming with C - Data Types.ppt
Structured Programming with C - Data Types.pptStructured Programming with C - Data Types.ppt
Structured Programming with C - Data Types.ppt
EmmanuelGathu
 
Constant, variables, data types
Constant, variables, data typesConstant, variables, data types
Constant, variables, data types
Pratik Devmurari
 
C language (Collected By Dushmanta)
C language  (Collected By Dushmanta)C language  (Collected By Dushmanta)
C language (Collected By Dushmanta)
Dushmanta Nath
 
C programming session 01
C programming session 01C programming session 01
C programming session 01
AjayBahoriya
 
2 1. variables & data types
2 1. variables & data types2 1. variables & data types
2 1. variables & data types
웅식 전
 
Data types slides by Faixan
Data types slides by FaixanData types slides by Faixan
Data types slides by Faixan
ٖFaiXy :)
 
Data Type in C Programming
Data Type in C ProgrammingData Type in C Programming
Data Type in C Programming
Qazi Shahzad Ali
 
A Closer Look at Data Types, Variables and Expressions
A Closer Look at Data Types, Variables and ExpressionsA Closer Look at Data Types, Variables and Expressions
A Closer Look at Data Types, Variables and Expressions
Inan Mashrur
 
2. Variables and Data Types in C++ proramming.pptx
2. Variables and Data Types in C++ proramming.pptx2. Variables and Data Types in C++ proramming.pptx
2. Variables and Data Types in C++ proramming.pptx
Ahmad177077
 
Data Types in C
Data Types in CData Types in C
Data Types in C
yarkhosh
 
FP 201 Unit 2 - Part 2
FP 201 Unit 2 - Part 2FP 201 Unit 2 - Part 2
FP 201 Unit 2 - Part 2
rohassanie
 
Structured Programming with C - Data Types.ppt
Structured Programming with C - Data Types.pptStructured Programming with C - Data Types.ppt
Structured Programming with C - Data Types.ppt
EmmanuelGathu
 

Recently uploaded (20)

Cybersecurity for Business Students as a RESOURCE SPEAKER 2021
Cybersecurity for Business Students as a RESOURCE SPEAKER 2021Cybersecurity for Business Students as a RESOURCE SPEAKER 2021
Cybersecurity for Business Students as a RESOURCE SPEAKER 2021
MELJUN CORTES
 
A Brief Introduction About Gregory Felber
A Brief Introduction About Gregory FelberA Brief Introduction About Gregory Felber
A Brief Introduction About Gregory Felber
Gregory Felber
 
OwnAir - Your Cinema Everywhere | Business Plan
OwnAir - Your Cinema Everywhere | Business PlanOwnAir - Your Cinema Everywhere | Business Plan
OwnAir - Your Cinema Everywhere | Business Plan
Alessandro Masi
 
Project - About Balloonerism the short film.
Project - About Balloonerism the short film.Project - About Balloonerism the short film.
Project - About Balloonerism the short film.
jyncxjrx7y
 
Conference 2 Notes for Car and Home Show.pdf
Conference 2 Notes for Car and Home Show.pdfConference 2 Notes for Car and Home Show.pdf
Conference 2 Notes for Car and Home Show.pdf
Brij Consulting, LLC
 
Daniel E. Kaplan - Dedication To Financial Excellence
Daniel E. Kaplan - Dedication To Financial ExcellenceDaniel E. Kaplan - Dedication To Financial Excellence
Daniel E. Kaplan - Dedication To Financial Excellence
Daniel E. Kaplan
 
Oleksandr Osypenko: Introduction to PMO (UA)
Oleksandr Osypenko: Introduction to PMO (UA)Oleksandr Osypenko: Introduction to PMO (UA)
Oleksandr Osypenko: Introduction to PMO (UA)
Lviv Startup Club
 
Event Report - SAP Sapphire 2025 Orlando - Good work more to come
Event Report - SAP Sapphire 2025 Orlando - Good work more to comeEvent Report - SAP Sapphire 2025 Orlando - Good work more to come
Event Report - SAP Sapphire 2025 Orlando - Good work more to come
Holger Mueller
 
The Product-Market Fit Staircase (for consumer businesses)
The Product-Market Fit Staircase (for consumer businesses)The Product-Market Fit Staircase (for consumer businesses)
The Product-Market Fit Staircase (for consumer businesses)
ssuser276a18
 
Research Proposal for fist three chapter.pdf
Research Proposal for fist three chapter.pdfResearch Proposal for fist three chapter.pdf
Research Proposal for fist three chapter.pdf
moh09152269
 
HVAC Filter Test .pdf
HVAC Filter Test                    .pdfHVAC Filter Test                    .pdf
HVAC Filter Test .pdf
Test Master
 
Bubble Tea Market: Trends, Growth, and Future Outlook
Bubble Tea Market: Trends, Growth, and Future OutlookBubble Tea Market: Trends, Growth, and Future Outlook
Bubble Tea Market: Trends, Growth, and Future Outlook
chanderdeepseoexpert
 
Europe Toys Market Size, Share, Trends & Report | 2034
Europe Toys Market Size, Share, Trends & Report | 2034Europe Toys Market Size, Share, Trends & Report | 2034
Europe Toys Market Size, Share, Trends & Report | 2034
GeorgeButtler
 
Smart Support, Virtually Delivered: Powering Productivity with OnestopDA
Smart Support, Virtually Delivered: Powering Productivity with OnestopDASmart Support, Virtually Delivered: Powering Productivity with OnestopDA
Smart Support, Virtually Delivered: Powering Productivity with OnestopDA
OnestopDA
 
introduction to business marketin.g
introduction  to business     marketin.gintroduction  to business     marketin.g
introduction to business marketin.g
muzzushik
 
Market Dynamics Sample Report - Redacted
Market Dynamics Sample Report - RedactedMarket Dynamics Sample Report - Redacted
Market Dynamics Sample Report - Redacted
Mintel Group
 
Water Pump Market Size, Share and Forecast | 2025-2034
Water Pump Market Size, Share and Forecast | 2025-2034Water Pump Market Size, Share and Forecast | 2025-2034
Water Pump Market Size, Share and Forecast | 2025-2034
GeorgeButtler
 
PCAT Prime Corporate Accounting and Tax Services
PCAT Prime Corporate Accounting and Tax ServicesPCAT Prime Corporate Accounting and Tax Services
PCAT Prime Corporate Accounting and Tax Services
sohail856510
 
FedEx_TQM_QDM_PSP_Presentation52925.pptx
FedEx_TQM_QDM_PSP_Presentation52925.pptxFedEx_TQM_QDM_PSP_Presentation52925.pptx
FedEx_TQM_QDM_PSP_Presentation52925.pptx
RaulAmavisca
 
Mining Saudi Arabia Monthly Report May 2025
Mining Saudi Arabia Monthly Report May 2025Mining Saudi Arabia Monthly Report May 2025
Mining Saudi Arabia Monthly Report May 2025
Tendayi Mwayi
 
Cybersecurity for Business Students as a RESOURCE SPEAKER 2021
Cybersecurity for Business Students as a RESOURCE SPEAKER 2021Cybersecurity for Business Students as a RESOURCE SPEAKER 2021
Cybersecurity for Business Students as a RESOURCE SPEAKER 2021
MELJUN CORTES
 
A Brief Introduction About Gregory Felber
A Brief Introduction About Gregory FelberA Brief Introduction About Gregory Felber
A Brief Introduction About Gregory Felber
Gregory Felber
 
OwnAir - Your Cinema Everywhere | Business Plan
OwnAir - Your Cinema Everywhere | Business PlanOwnAir - Your Cinema Everywhere | Business Plan
OwnAir - Your Cinema Everywhere | Business Plan
Alessandro Masi
 
Project - About Balloonerism the short film.
Project - About Balloonerism the short film.Project - About Balloonerism the short film.
Project - About Balloonerism the short film.
jyncxjrx7y
 
Conference 2 Notes for Car and Home Show.pdf
Conference 2 Notes for Car and Home Show.pdfConference 2 Notes for Car and Home Show.pdf
Conference 2 Notes for Car and Home Show.pdf
Brij Consulting, LLC
 
Daniel E. Kaplan - Dedication To Financial Excellence
Daniel E. Kaplan - Dedication To Financial ExcellenceDaniel E. Kaplan - Dedication To Financial Excellence
Daniel E. Kaplan - Dedication To Financial Excellence
Daniel E. Kaplan
 
Oleksandr Osypenko: Introduction to PMO (UA)
Oleksandr Osypenko: Introduction to PMO (UA)Oleksandr Osypenko: Introduction to PMO (UA)
Oleksandr Osypenko: Introduction to PMO (UA)
Lviv Startup Club
 
Event Report - SAP Sapphire 2025 Orlando - Good work more to come
Event Report - SAP Sapphire 2025 Orlando - Good work more to comeEvent Report - SAP Sapphire 2025 Orlando - Good work more to come
Event Report - SAP Sapphire 2025 Orlando - Good work more to come
Holger Mueller
 
The Product-Market Fit Staircase (for consumer businesses)
The Product-Market Fit Staircase (for consumer businesses)The Product-Market Fit Staircase (for consumer businesses)
The Product-Market Fit Staircase (for consumer businesses)
ssuser276a18
 
Research Proposal for fist three chapter.pdf
Research Proposal for fist three chapter.pdfResearch Proposal for fist three chapter.pdf
Research Proposal for fist three chapter.pdf
moh09152269
 
HVAC Filter Test .pdf
HVAC Filter Test                    .pdfHVAC Filter Test                    .pdf
HVAC Filter Test .pdf
Test Master
 
Bubble Tea Market: Trends, Growth, and Future Outlook
Bubble Tea Market: Trends, Growth, and Future OutlookBubble Tea Market: Trends, Growth, and Future Outlook
Bubble Tea Market: Trends, Growth, and Future Outlook
chanderdeepseoexpert
 
Europe Toys Market Size, Share, Trends & Report | 2034
Europe Toys Market Size, Share, Trends & Report | 2034Europe Toys Market Size, Share, Trends & Report | 2034
Europe Toys Market Size, Share, Trends & Report | 2034
GeorgeButtler
 
Smart Support, Virtually Delivered: Powering Productivity with OnestopDA
Smart Support, Virtually Delivered: Powering Productivity with OnestopDASmart Support, Virtually Delivered: Powering Productivity with OnestopDA
Smart Support, Virtually Delivered: Powering Productivity with OnestopDA
OnestopDA
 
introduction to business marketin.g
introduction  to business     marketin.gintroduction  to business     marketin.g
introduction to business marketin.g
muzzushik
 
Market Dynamics Sample Report - Redacted
Market Dynamics Sample Report - RedactedMarket Dynamics Sample Report - Redacted
Market Dynamics Sample Report - Redacted
Mintel Group
 
Water Pump Market Size, Share and Forecast | 2025-2034
Water Pump Market Size, Share and Forecast | 2025-2034Water Pump Market Size, Share and Forecast | 2025-2034
Water Pump Market Size, Share and Forecast | 2025-2034
GeorgeButtler
 
PCAT Prime Corporate Accounting and Tax Services
PCAT Prime Corporate Accounting and Tax ServicesPCAT Prime Corporate Accounting and Tax Services
PCAT Prime Corporate Accounting and Tax Services
sohail856510
 
FedEx_TQM_QDM_PSP_Presentation52925.pptx
FedEx_TQM_QDM_PSP_Presentation52925.pptxFedEx_TQM_QDM_PSP_Presentation52925.pptx
FedEx_TQM_QDM_PSP_Presentation52925.pptx
RaulAmavisca
 
Mining Saudi Arabia Monthly Report May 2025
Mining Saudi Arabia Monthly Report May 2025Mining Saudi Arabia Monthly Report May 2025
Mining Saudi Arabia Monthly Report May 2025
Tendayi Mwayi
 

Lecture 2 introduction to Programming languages C.pptx

  • 1. Survey of Programming Languages Introduction to C-Language Lecture 2
  • 2. Levels of Programming Languages There are 3 levels of programming languages i) High-Level Language ii) Middle-Level Language iii) Low-Level Language
  • 3. A First Program (C ) #include <stdio.h> int main(void) { printf("This is my first C program.n"); return(0); } statements header open and close braces mark the beginning and end makes input and output available to us
  • 4. A First Program – What Does It Do? printf("This is my first C program.n"); return(0); Prints the message This is my first C program. Ends the program Ends the line
  • 5. White Space Characters •The character that produces blank space when printed is called a white space character, e.g. •Spaces •Tabs •New Lines
  • 7. Data types and Sizes •There are three main data types in C/C++ i) Character char ii) Integer int iii) Floating Point float
  • 8. Character data type • Represented by char • used for storing a character, digit or special character. • A character constant must be enclosed in single quotations i.e. ‘A’, ‘1’ or ‘*’ etc. • uses/occupies one byte( 8 bits) of memory. • character constant can be signed or unsigned.
  • 9. Character data type •There are 3 types of character data type, i.e. char, signed char and unsigned char. e.g. •char age means signed char •signed char code means signed char •unsigned char value means unsigned char •The value range of binary numbers in: •Char -128 to 127 or 0 to 255 •signed char is from -128 to +127 •unsigned char is from 0 to 255
  • 10. Integer data type •Integer data type is represented by int •used for storing Integers, i.e. numeric values without decimal portions. •RANGE: Store a value ranging from -32,768 to + 32,767 •MEMORY: 2 bytes of memory •Integer data type is also represented as •Short •long
  • 11. Integer data types int 2 or 4 bytes -32,768 to 32,767 or - 2,147,483,648 to 2,147,483,647 short 2 bytes -32,768 to 32,767 long 4 bytes -2,147,483,648 to 2,147,483,647 Type Storage size Value Range
  • 12. Integer data type •Another int type is signed int which is used to store sign too along with the numeric value. •Another int type is unsigned int which is used to store values without sign •So, there are 9 types of Integer data types, i.e. int, short, signed int, unsigned int, signed short, unsigned short, long, signed long and unsigned long e.g.
  • 13. Type Storage size Value range char 1 byte -128 to 127 or 0 to 255 unsigned char 1 byte 0 to 255 signed char 1 byte -128 to 127 int 2 or 4 bytes -32,768 to 32,767 or -2,147,483,648 to 2,147,483,647 unsigned int 2 or 4 bytes 0 to 65,535 or 0 to 4,294,967,295 short 2 bytes -32,768 to 32,767 unsigned short 2 bytes 0 to 65,535 long 4 bytes -2,147,483,648 to 2,147,483,647 unsigned long 4 bytes 0 to 4,294,967,295
  • 14. Examples •int a; means signed int •signed int b; means signed int •unsigned int c; means unsigned int •short d; means signed short •signed short e; means signed short •unsigned short f; means unsigned short •long g; means signed long •signed long h; means signed long •unsigned long I; means unsigned long
  • 15. Float data type •Float data type is represented by float and is used for storing numeric values •Means fraction or decimal portion. •Float data type takes 4 bytes of memory. • A floating point number is expressed in scientific notation. •The reason of storing float values in scientific notation is that they can be very large or extremely small.
  • 16. Float data type •2000000000000000 = 2e+15 •0.00000000000023 = 2.3e-13 •A value written as 47e3 means 47 x 10^3 •Exponent value ranges from -38 to +38, i.e. 47x10^- 38 to 47x10^+38 •Another float type is double that takes 8 bytes of memory. •Exponent values in double ranges from -308 to + 308, i.e. 47x10-308 to 47x10+308
  • 17. Data types Name Description Size* Range* char Character or small integer. 1byte signed: -128 to 127 unsigned: 0 to 255 short int (short) Short Integer. 2bytes signed: -32768 to 32767 unsigned: 0 to 65535 int Integer. 2bytes signed: -32768 to 32767 unsigned: 0 to 65535 long int (long) Long integer. 4bytes signed: -2147483648 to 2147483647 unsigned: 0 to 4294967295 bool Boolean value. It can take one of two values: true or false. 1byte true or false float Floating point number. 4bytes +/- 3.4e +/- 38 (~7 digits) double Double precision floating point number. 8bytes +/- 1.7e +/- 308 (~15 digits) long double Long double precision floating point number. 8bytes +/- 1.7e +/- 308 (~15 digits)
  • 18. Practice • char myGrade = 'B'; • char a = 65, b = 66, c = 67; • string greeting = "Hello"; • float f1 = 35e3; • double d1 = 12E4; • bool isCodingFun = true; • bool isFishTasty = false;

Editor's Notes

  • #9: Uchar= 1 byte short/unshort= 2 bytes Int 4 bytes Long 8 bytes
  • #10: the range of 8-bit unsigned binary numbers is from 0 to 25510 in decimal and from 00 to FF16 in hexadecimal. ... The most significant bit of a binary number is used to represent the sign bit.