SlideShare a Scribd company logo
1 of 31
Variable Declaration
IT - 121
11/12/2015
Variable
This refers to the named area in memory that stores a value or string
assigned to that variable. It is named storage location capable of
containing a certain type of data that can be modified during program
execution.
A variable is nothing but a name given to a storage area that our programs
can manipulate. 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.
C Language
2
6
:
5
5
A
M
11/12/2015
Variable
The name of a variable can be composed of letters, digits, and the
underscore character. It must begin with either a letter or an
underscore. Upper and lowercase letters are distinct because C is
case-sensitive.
Example:
 number
 _myAge
 sum1
6
:
5
5
A
M
C Language
3
11/12/2015
Data Types
This is a definition of a set of data that specifies the possible range of
values of the set, the operations that can be performed on the values,
and the way in which the values are stored in memory. Knowing the
type of data enables the computer to manipulate it appropriately.
Data types in C refer to an extensive system used for declaring variables or
functions of different types. The type of a variable determines how much
space it occupies in storage and how the bit pattern stored is interpreted.
6
:
5
5
A
M
C Language
4
11/12/2015
Basic Data Types: Integer Type
The following table provides the details of standard integer types with
their storage sizes and value ranges.
6
:
5
5
A
M
C Language
5
11/12/2015
Basic Data Types: Integer Type
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
6
:
5
5
A
M
C Language
6
11/12/2015
Basic Data Types: Floating-Point Type
The following table provide the details of standard floating-point
types with storage sizes and value ranges and their precision.
6
:
5
5
A
M
C Language
7
11/12/2015
Basic Data Types: Floating-Point Type
Type Storage size Value range Precision
float 4 byte 1.2E-38 to 3.4E+38 6 decimal places
double 8 byte 2.3E-308 to 1.7E+308 15 decimal places
long double 10 byte 3.4E-4932 to 1.1E+4932 19 decimal places
6
:
5
5
A
M
C Language
8
11/12/2015
Constants
Constants refer to fixed values that the program may not alter during
its execution. These fixed values are also called literals.
Constants can be of any of the basic data types like an integer
constant, a floating constant, a character constant, or a string literal.
Constants are treated just like regular variables except that their values
cannot be modified after their definition.
6
:
5
5
A
M
C Language
9
11/12/2015
Constants: Integer Literals
An integer literal can be a decimal, octal, or hexadecimal constant. A
prefix specifies the base or radix: 0x or 0X for hexadecimal, 0 for octal,
and nothing for decimal.
An integer literal can also have a suffix that is a combination of U and L, for
unsigned and long, respectively. The suffix can be uppercase or lowercase and
can be in any order.
6
:
5
5
A
M
C Language
10
11/12/2015
Constants: Integer Literals
 Example:
 212 /* Legal */
 215u /* Legal */
 0xFeeL /* Legal */
 078 /* Illegal: 8 is not an octal digit */
 032UU /* Illegal: cannot repeat a suffix */
 85 /* decimal */
 0213 /* octal */
 0x4b /* hexadecimal */
 30 /* int */
 30u /* unsigned int */
 30l /* long */
 30ul /* unsigned long */
6
:
5
5
A
M
C Language
11
11/12/2015
Constants: Floating-point Literals
A floating-point literal has an integer part, a decimal point, a
fractional part, and an exponent part. You can represent floating point
literals either in decimal form or exponential form.
While representing decimal form, you must include the decimal point, the
exponent, or both; and while representing exponential form, you must
include the integer part, the fractional part, or both. The signed exponent is
introduced by e or E.
6
:
5
5
A
M
C Language
12
11/12/2015
Constants: Floating-point Literals
Example:
3.14159 /* Legal */
314159E-5L /* Legal */
510E /* Illegal: incomplete exponent */
210f /* Illegal: no decimal or exponent */
.e55 /* Illegal: missing integer or fraction */
6
:
5
5
A
M
C Language
13
11/12/2015
Constants: Character Constants
Character literals are enclosed in single quotes, e.g., 'x' can be stored
in a simple variable of char type.
A character literal can be a plain character (e.g., 'x'), an escape
sequence (e.g., 't'), or a universal character (e.g., 'u02C0').
There are certain characters in C that represent special meaning
when preceded by a backslash for example, newline (n) or tab (t).
6
:
5
5
A
M
C Language
14
11/12/2015
Constants: Character Constants
Escape sequence Meaning Escape sequence Meaning
  character n Newline
' ' character r Carriage return
" " character t Horizontal tab
? ? character v Vertical tab
a Alert or bell ooo Octal number of one to three digits
b Backspace xhh . . . Hexadecimal number of one or more digits
f Form feed
6
:
5
5
A
M
C Language
15
11/12/2015
Constants: String Literals
String literals or constants are enclosed in double quotes "". A string
contains characters that are similar to character literals: plain
characters, escape sequences, and universal characters.
You can break a long line into multiple lines using string literals and
separating them using white spaces.
6
:
5
5
A
M
C Language
16
11/12/2015
Constants: String Literals
Example:
"hello, dear"
"hello, 
dear"
"hello, " "d" "ear"
6
:
5
5
A
M
C Language
17
11/12/2015
Operators
An operator is a symbol that tells the compiler to perform specific
mathematical or logical functions. C language is rich in built-in
operators and provides the following types of operators.
Arithmetic Operators
Relational Operators
Logical Operators
6
:
5
5
A
M
C Language
18
11/12/2015
Arithmetic Operators
The following table shows all the arithmetic operators supported by the C
language. Assume variable A holds 10 and variable B holds 20.
6
:
5
5
A
M
C Language
19
11/12/2015
Arithmetic Operators
Operator Description Example
+ Adds two operands. A + B = 30
− Subtracts second operand from the first. A − B = 10
* Multiplies both operands. A * B = 200
/ Divides numerator by de-numerator. B / A = 2
% Modulus Operator and remainder of after an integer division. B % A = 0
++ Increment operator increases the integer value by one. A++ = 11
-- Decrement operator decreases the integer value by one. A-- = 9
6
:
5
5
A
M
C Language
20
11/12/2015
Relational Operators
The following table shows all the relational operators supported by C. Assume
variable A holds 10 and variable B holds 20.
6
:
5
5
A
M
C Language
21
11/12/2015
Relational Operators
Operator Description Example
== Checks if the values of two operands are equal or not. If yes, then the
condition becomes true.
(A == B) is not true.
!= Checks if the values of two operands are equal or not. If the values are
not equal, then the condition becomes true.
(A != B) is true.
> Checks if the value of left operand is greater than the value of right
operand. If yes, then the condition becomes true.
(A > B) is not true.
< Checks if the value of left operand is less than the value of right operand.
If yes, then the condition becomes true.
(A < B) is true.
>= Checks if the value of left operand is greater than or equal to the value of
right operand. If yes, then the condition becomes true.
(A >= B) is not true.
<= Checks if the value of left operand is less than or equal to the value of
right operand. If yes, then the condition becomes true.
(A <= B) is true.
6
:
5
5
A
M
C Language
22
11/12/2015
Logical Operators
Following table shows all the logical operators supported by C language.
Assume variable A holds 1 and variable B holds 0.
6
:
5
5
A
M
C Language
23
11/12/2015
Logical Operators
Operator Description Example
&& Called Logical AND operator. If both the operands are non-zero, then the
condition becomes true.
(A && B) is false.
|| Called Logical OR Operator. If any of the two operands is non-zero, then the
condition becomes true.
(A || B) is true.
! Called Logical NOT Operator. It is used to reverse the logical state of its
operand. If a condition is true, then Logical NOT operator will make it false.
!(A && B) is true.
6
:
5
5
A
M
C Language
24
11/12/2015
C - Program Structure
A C program basically consists of the following parts:
Preprocessor Commands
Functions
Variables
Statements & Expressions
Comments
6
:
5
5
A
M
C Language
25
11/12/2015
C - Program Structure
#include <stdio.h>
int main()
{
 /* my first program in C */
 printf("Hello, World! n");
 return 0;
}
6
:
5
5
A
M
C Language
26
11/12/2015
C - Program Structure
Let us take a look at the various parts of the above program −
The first line of the program #include <stdio.h> is a preprocessor command,
which tells a C compiler to include stdio.h file before going to actual
compilation.
The next line /*...*/ will be ignored by the compiler and it has been put to add
additional comments in the program. So such lines are called comments in the
program.
The next line return 0; terminates the main() function and returns the value 0.
6
:
5
5
A
M
C Language
27
C - INPUT & OUTPUT
6:55 AMC Language 28
11/12/2015
C - Input & Output
When we say Input, it means to feed some data into a program. An
input can be given in the form of a file or from the command line. C
programming provides a set of built-in functions to read the given
input and feed it to the program as per requirement.
When we say Output, it means to display some data on screen,
printer, or in any file. C programming provides a set of built-in
functions to output the data on the computer screen as well as to
save it in text or binary files.
6
:
5
5
A
M
C Language
29
11/12/2015
The scanf() and printf() Functions
The int scanf(const char *format, ...) function reads the input from
the standard input stream stdin and scans that input according to
the formatprovided.
The int printf(const char *format, ...) function writes the output to
the standard output stream stdout and produces the output
according to the format provided.
The format can be a simple constant string, but you can specify %s,
%d, %c, %f, etc., to print or read strings, integer, character or float
respectively. There are many other formatting options available which
can be used based on requirements.
6
:
5
5
A
M
C Language
30
11/12/2015
Example:
#include <stdio.h>
int main( )
{
 char str[100];
 int i;
 printf( "Enter a value :");
 scanf("%s %d", str, &i);
 printf( "nYou entered: %s %d ", str, i);
 return 0;
}
6
:
5
5
A
M
C Language
31

More Related Content

What's hot

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 JyothiSowmyaJyothi3
 
datatypes and variables in c language
 datatypes and variables in c language datatypes and variables in c language
datatypes and variables in c languageRai University
 
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 handlingRai University
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C ProgrammingQazi Shahzad Ali
 
Unit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in CUnit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in CSowmya Jyothi
 
Constant, variables, data types
Constant, variables, data typesConstant, variables, data types
Constant, variables, data typesPratik Devmurari
 
Numeric Data Types & Strings
Numeric Data Types & StringsNumeric Data Types & Strings
Numeric Data Types & StringsAbhinav Porwal
 
Constants and variables in c programming
Constants and variables in c programmingConstants and variables in c programming
Constants and variables in c programmingChitrank Dixit
 
Data Types and Variables In C Programming
Data Types and Variables In C ProgrammingData Types and Variables In C Programming
Data Types and Variables In C ProgrammingKamal Acharya
 

What's hot (19)

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
 
datatypes and variables in c language
 datatypes and variables in c language datatypes and variables in c language
datatypes and variables in c language
 
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
 
Assignment7
Assignment7Assignment7
Assignment7
 
C –imp points
C –imp pointsC –imp points
C –imp points
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
Unit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in CUnit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in C
 
Constant, variables, data types
Constant, variables, data typesConstant, variables, data types
Constant, variables, data types
 
Numeric Data Types & Strings
Numeric Data Types & StringsNumeric Data Types & Strings
Numeric Data Types & Strings
 
CHAPTER 2
CHAPTER 2CHAPTER 2
CHAPTER 2
 
Python Programming
Python ProgrammingPython Programming
Python Programming
 
Assignment10
Assignment10Assignment10
Assignment10
 
Data types
Data typesData types
Data types
 
C Token’s
C Token’sC Token’s
C Token’s
 
C language basics
C language basicsC language basics
C language basics
 
Constants and variables in c programming
Constants and variables in c programmingConstants and variables in c programming
Constants and variables in c programming
 
Data Types and Variables In C Programming
Data Types and Variables In C ProgrammingData Types and Variables In C Programming
Data Types and Variables In C Programming
 
Assignment12
Assignment12Assignment12
Assignment12
 
Lecture02(constants, variable & data types)
Lecture02(constants, variable & data types)Lecture02(constants, variable & data types)
Lecture02(constants, variable & data types)
 

Viewers also liked

World 4 th quarter outline
World 4 th quarter outlineWorld 4 th quarter outline
World 4 th quarter outlineHanielle Cheng
 
The reformation part i
The reformation part iThe reformation part i
The reformation part iHanielle Cheng
 
4th quarter periodic test review in math3
4th quarter periodic test review in math34th quarter periodic test review in math3
4th quarter periodic test review in math3Hanielle Cheng
 
4th quarter periodic test review in trigonometry
4th quarter periodic test review in trigonometry4th quarter periodic test review in trigonometry
4th quarter periodic test review in trigonometryHanielle Cheng
 

Viewers also liked (6)

World 4 th quarter outline
World 4 th quarter outlineWorld 4 th quarter outline
World 4 th quarter outline
 
Quiz no.5
Quiz no.5Quiz no.5
Quiz no.5
 
The reformation part i
The reformation part iThe reformation part i
The reformation part i
 
The renaissance
The renaissanceThe renaissance
The renaissance
 
4th quarter periodic test review in math3
4th quarter periodic test review in math34th quarter periodic test review in math3
4th quarter periodic test review in math3
 
4th quarter periodic test review in trigonometry
4th quarter periodic test review in trigonometry4th quarter periodic test review in trigonometry
4th quarter periodic test review in trigonometry
 

Similar to Variable Declaration in C - Data Types, Constants, Operators

Learning c - An extensive guide to learn the C Language
Learning c - An extensive guide to learn the C LanguageLearning c - An extensive guide to learn the C Language
Learning c - An extensive guide to learn the C LanguageAbhishek Dwivedi
 
C_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptxC_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptxLikhil181
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C ProgrammingMOHAMAD NOH AHMAD
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 FocJAYA
 
C programming language
C programming languageC programming language
C programming languageAbin Rimal
 
Unit 2 c programming_basics
Unit 2 c programming_basicsUnit 2 c programming_basics
Unit 2 c programming_basicskirthika jeyenth
 
C Language (All Concept)
C Language (All Concept)C Language (All Concept)
C Language (All Concept)sachindane
 
Learn C# Programming - Variables & Constants
Learn C# Programming - Variables & ConstantsLearn C# Programming - Variables & Constants
Learn C# Programming - Variables & ConstantsEng Teong Cheah
 
C Sharp Nagina (1)
C Sharp Nagina (1)C Sharp Nagina (1)
C Sharp Nagina (1)guest58c84c
 
C Sharp Jn (1)
C Sharp Jn (1)C Sharp Jn (1)
C Sharp Jn (1)jahanullah
 
Programming construction tools
Programming construction toolsProgramming construction tools
Programming construction toolssunilchute1
 

Similar to Variable Declaration in C - Data Types, Constants, Operators (20)

Presentation 2
Presentation 2Presentation 2
Presentation 2
 
Learning c - An extensive guide to learn the C Language
Learning c - An extensive guide to learn the C LanguageLearning c - An extensive guide to learn the C Language
Learning c - An extensive guide to learn the C Language
 
CProgrammingTutorial
CProgrammingTutorialCProgrammingTutorial
CProgrammingTutorial
 
C_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptxC_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptx
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 Foc
 
C programming language
C programming languageC programming language
C programming language
 
PSPC--UNIT-2.pdf
PSPC--UNIT-2.pdfPSPC--UNIT-2.pdf
PSPC--UNIT-2.pdf
 
C
CC
C
 
6276830.ppt
6276830.ppt6276830.ppt
6276830.ppt
 
Unit 2 c programming_basics
Unit 2 c programming_basicsUnit 2 c programming_basics
Unit 2 c programming_basics
 
CP Handout#3
CP Handout#3CP Handout#3
CP Handout#3
 
C Language (All Concept)
C Language (All Concept)C Language (All Concept)
C Language (All Concept)
 
Ch02
Ch02Ch02
Ch02
 
5 introduction-to-c
5 introduction-to-c5 introduction-to-c
5 introduction-to-c
 
C Language Part 1
C Language Part 1C Language Part 1
C Language Part 1
 
Learn C# Programming - Variables & Constants
Learn C# Programming - Variables & ConstantsLearn C# Programming - Variables & Constants
Learn C# Programming - Variables & Constants
 
C Sharp Nagina (1)
C Sharp Nagina (1)C Sharp Nagina (1)
C Sharp Nagina (1)
 
C Sharp Jn (1)
C Sharp Jn (1)C Sharp Jn (1)
C Sharp Jn (1)
 
Programming construction tools
Programming construction toolsProgramming construction tools
Programming construction tools
 

Recently uploaded

Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Paul Calvano
 
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With RoomVIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Roomdivyansh0kumar0
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts servicevipmodelshub1
 
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一Fs
 
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一Fs
 
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on DeliveryCall Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Deliverybabeytanya
 
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)Christopher H Felton
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja VipCall Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja VipCall Girls Lucknow
 
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一z xss
 
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一3sw2qly1
 
VIP Kolkata Call Girl Kestopur 👉 8250192130 Available With Room
VIP Kolkata Call Girl Kestopur 👉 8250192130  Available With RoomVIP Kolkata Call Girl Kestopur 👉 8250192130  Available With Room
VIP Kolkata Call Girl Kestopur 👉 8250192130 Available With Roomdivyansh0kumar0
 
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一Fs
 
Denver Web Design brochure for public viewing
Denver Web Design brochure for public viewingDenver Web Design brochure for public viewing
Denver Web Design brochure for public viewingbigorange77
 
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作ys8omjxb
 
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Dana Luther
 

Recently uploaded (20)

Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
 
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24
 
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With RoomVIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
 
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
 
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
 
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on DeliveryCall Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
 
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja VipCall Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
 
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
 
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
 
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一
 
VIP Kolkata Call Girl Kestopur 👉 8250192130 Available With Room
VIP Kolkata Call Girl Kestopur 👉 8250192130  Available With RoomVIP Kolkata Call Girl Kestopur 👉 8250192130  Available With Room
VIP Kolkata Call Girl Kestopur 👉 8250192130 Available With Room
 
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
 
Denver Web Design brochure for public viewing
Denver Web Design brochure for public viewingDenver Web Design brochure for public viewing
Denver Web Design brochure for public viewing
 
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
 
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
 

Variable Declaration in C - Data Types, Constants, Operators

  • 2. 11/12/2015 Variable This refers to the named area in memory that stores a value or string assigned to that variable. It is named storage location capable of containing a certain type of data that can be modified during program execution. A variable is nothing but a name given to a storage area that our programs can manipulate. 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. C Language 2 6 : 5 5 A M
  • 3. 11/12/2015 Variable The name of a variable can be composed of letters, digits, and the underscore character. It must begin with either a letter or an underscore. Upper and lowercase letters are distinct because C is case-sensitive. Example:  number  _myAge  sum1 6 : 5 5 A M C Language 3
  • 4. 11/12/2015 Data Types This is a definition of a set of data that specifies the possible range of values of the set, the operations that can be performed on the values, and the way in which the values are stored in memory. Knowing the type of data enables the computer to manipulate it appropriately. Data types in C refer to an extensive system used for declaring variables or functions of different types. The type of a variable determines how much space it occupies in storage and how the bit pattern stored is interpreted. 6 : 5 5 A M C Language 4
  • 5. 11/12/2015 Basic Data Types: Integer Type The following table provides the details of standard integer types with their storage sizes and value ranges. 6 : 5 5 A M C Language 5
  • 6. 11/12/2015 Basic Data Types: Integer Type 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 6 : 5 5 A M C Language 6
  • 7. 11/12/2015 Basic Data Types: Floating-Point Type The following table provide the details of standard floating-point types with storage sizes and value ranges and their precision. 6 : 5 5 A M C Language 7
  • 8. 11/12/2015 Basic Data Types: Floating-Point Type Type Storage size Value range Precision float 4 byte 1.2E-38 to 3.4E+38 6 decimal places double 8 byte 2.3E-308 to 1.7E+308 15 decimal places long double 10 byte 3.4E-4932 to 1.1E+4932 19 decimal places 6 : 5 5 A M C Language 8
  • 9. 11/12/2015 Constants Constants refer to fixed values that the program may not alter during its execution. These fixed values are also called literals. Constants can be of any of the basic data types like an integer constant, a floating constant, a character constant, or a string literal. Constants are treated just like regular variables except that their values cannot be modified after their definition. 6 : 5 5 A M C Language 9
  • 10. 11/12/2015 Constants: Integer Literals An integer literal can be a decimal, octal, or hexadecimal constant. A prefix specifies the base or radix: 0x or 0X for hexadecimal, 0 for octal, and nothing for decimal. An integer literal can also have a suffix that is a combination of U and L, for unsigned and long, respectively. The suffix can be uppercase or lowercase and can be in any order. 6 : 5 5 A M C Language 10
  • 11. 11/12/2015 Constants: Integer Literals  Example:  212 /* Legal */  215u /* Legal */  0xFeeL /* Legal */  078 /* Illegal: 8 is not an octal digit */  032UU /* Illegal: cannot repeat a suffix */  85 /* decimal */  0213 /* octal */  0x4b /* hexadecimal */  30 /* int */  30u /* unsigned int */  30l /* long */  30ul /* unsigned long */ 6 : 5 5 A M C Language 11
  • 12. 11/12/2015 Constants: Floating-point Literals A floating-point literal has an integer part, a decimal point, a fractional part, and an exponent part. You can represent floating point literals either in decimal form or exponential form. While representing decimal form, you must include the decimal point, the exponent, or both; and while representing exponential form, you must include the integer part, the fractional part, or both. The signed exponent is introduced by e or E. 6 : 5 5 A M C Language 12
  • 13. 11/12/2015 Constants: Floating-point Literals Example: 3.14159 /* Legal */ 314159E-5L /* Legal */ 510E /* Illegal: incomplete exponent */ 210f /* Illegal: no decimal or exponent */ .e55 /* Illegal: missing integer or fraction */ 6 : 5 5 A M C Language 13
  • 14. 11/12/2015 Constants: Character Constants Character literals are enclosed in single quotes, e.g., 'x' can be stored in a simple variable of char type. A character literal can be a plain character (e.g., 'x'), an escape sequence (e.g., 't'), or a universal character (e.g., 'u02C0'). There are certain characters in C that represent special meaning when preceded by a backslash for example, newline (n) or tab (t). 6 : 5 5 A M C Language 14
  • 15. 11/12/2015 Constants: Character Constants Escape sequence Meaning Escape sequence Meaning character n Newline ' ' character r Carriage return " " character t Horizontal tab ? ? character v Vertical tab a Alert or bell ooo Octal number of one to three digits b Backspace xhh . . . Hexadecimal number of one or more digits f Form feed 6 : 5 5 A M C Language 15
  • 16. 11/12/2015 Constants: String Literals String literals or constants are enclosed in double quotes "". A string contains characters that are similar to character literals: plain characters, escape sequences, and universal characters. You can break a long line into multiple lines using string literals and separating them using white spaces. 6 : 5 5 A M C Language 16
  • 17. 11/12/2015 Constants: String Literals Example: "hello, dear" "hello, dear" "hello, " "d" "ear" 6 : 5 5 A M C Language 17
  • 18. 11/12/2015 Operators An operator is a symbol that tells the compiler to perform specific mathematical or logical functions. C language is rich in built-in operators and provides the following types of operators. Arithmetic Operators Relational Operators Logical Operators 6 : 5 5 A M C Language 18
  • 19. 11/12/2015 Arithmetic Operators The following table shows all the arithmetic operators supported by the C language. Assume variable A holds 10 and variable B holds 20. 6 : 5 5 A M C Language 19
  • 20. 11/12/2015 Arithmetic Operators Operator Description Example + Adds two operands. A + B = 30 − Subtracts second operand from the first. A − B = 10 * Multiplies both operands. A * B = 200 / Divides numerator by de-numerator. B / A = 2 % Modulus Operator and remainder of after an integer division. B % A = 0 ++ Increment operator increases the integer value by one. A++ = 11 -- Decrement operator decreases the integer value by one. A-- = 9 6 : 5 5 A M C Language 20
  • 21. 11/12/2015 Relational Operators The following table shows all the relational operators supported by C. Assume variable A holds 10 and variable B holds 20. 6 : 5 5 A M C Language 21
  • 22. 11/12/2015 Relational Operators Operator Description Example == Checks if the values of two operands are equal or not. If yes, then the condition becomes true. (A == B) is not true. != Checks if the values of two operands are equal or not. If the values are not equal, then the condition becomes true. (A != B) is true. > Checks if the value of left operand is greater than the value of right operand. If yes, then the condition becomes true. (A > B) is not true. < Checks if the value of left operand is less than the value of right operand. If yes, then the condition becomes true. (A < B) is true. >= Checks if the value of left operand is greater than or equal to the value of right operand. If yes, then the condition becomes true. (A >= B) is not true. <= Checks if the value of left operand is less than or equal to the value of right operand. If yes, then the condition becomes true. (A <= B) is true. 6 : 5 5 A M C Language 22
  • 23. 11/12/2015 Logical Operators Following table shows all the logical operators supported by C language. Assume variable A holds 1 and variable B holds 0. 6 : 5 5 A M C Language 23
  • 24. 11/12/2015 Logical Operators Operator Description Example && Called Logical AND operator. If both the operands are non-zero, then the condition becomes true. (A && B) is false. || Called Logical OR Operator. If any of the two operands is non-zero, then the condition becomes true. (A || B) is true. ! Called Logical NOT Operator. It is used to reverse the logical state of its operand. If a condition is true, then Logical NOT operator will make it false. !(A && B) is true. 6 : 5 5 A M C Language 24
  • 25. 11/12/2015 C - Program Structure A C program basically consists of the following parts: Preprocessor Commands Functions Variables Statements & Expressions Comments 6 : 5 5 A M C Language 25
  • 26. 11/12/2015 C - Program Structure #include <stdio.h> int main() {  /* my first program in C */  printf("Hello, World! n");  return 0; } 6 : 5 5 A M C Language 26
  • 27. 11/12/2015 C - Program Structure Let us take a look at the various parts of the above program − The first line of the program #include <stdio.h> is a preprocessor command, which tells a C compiler to include stdio.h file before going to actual compilation. The next line /*...*/ will be ignored by the compiler and it has been put to add additional comments in the program. So such lines are called comments in the program. The next line return 0; terminates the main() function and returns the value 0. 6 : 5 5 A M C Language 27
  • 28. C - INPUT & OUTPUT 6:55 AMC Language 28
  • 29. 11/12/2015 C - Input & Output When we say Input, it means to feed some data into a program. An input can be given in the form of a file or from the command line. C programming provides a set of built-in functions to read the given input and feed it to the program as per requirement. When we say Output, it means to display some data on screen, printer, or in any file. C programming provides a set of built-in functions to output the data on the computer screen as well as to save it in text or binary files. 6 : 5 5 A M C Language 29
  • 30. 11/12/2015 The scanf() and printf() Functions The int scanf(const char *format, ...) function reads the input from the standard input stream stdin and scans that input according to the formatprovided. The int printf(const char *format, ...) function writes the output to the standard output stream stdout and produces the output according to the format provided. The format can be a simple constant string, but you can specify %s, %d, %c, %f, etc., to print or read strings, integer, character or float respectively. There are many other formatting options available which can be used based on requirements. 6 : 5 5 A M C Language 30
  • 31. 11/12/2015 Example: #include <stdio.h> int main( ) {  char str[100];  int i;  printf( "Enter a value :");  scanf("%s %d", str, &i);  printf( "nYou entered: %s %d ", str, i);  return 0; } 6 : 5 5 A M C Language 31