0% found this document useful (0 votes)
14 views

Chapter 15 Datatypes Variables in 3minutes

Uploaded by

KundiLokesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Chapter 15 Datatypes Variables in 3minutes

Uploaded by

KundiLokesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Variables & Data

types in 3 minutes
SURESH TECHS
CHAPTER 15 C PROGRAMMING COURSE
Variables
• Variables are used to store the data
and it’s value can be changed at any
time

• Syntax:
• type variable
• type variable1, variable2

• Ex:
• int a;
• long int la;
• float b;
• char c;
Rules for defining Variables
• A variable can have alphabets, digits, and underscore.
• A variable name can start with the alphabet, and underscore only. It
can't start with a digit.
• No whitespace is allowed within the variable name.
• A variable name must not be a keyword
Types of Variables
• local variable
• global variable
• static variable
• automatic variable
• external variable

Will discuss in
storage classes chapter
Data types
Data types
• A data type defines the type of data and size of the data

Data types

Primary Secondary
Data types Data types

Alpha User
Numeric Derived
numeric defined

Integer Decimal Character


Primary / Basic data types Secondary
Data types

User Derived
Defined Data types

Structure
Array

Union String

Typedef Pointer

Enum Functions
int data type
• It holds integers(negative integers, zero and positive integers).

• The keyword "int" is used to declare the integer data type and the
format specifier is denoted by "%d".

• We can also use different type modifiers with this data type.

• They are short, long, signed and unsigned.


int data type
• The short keyword reduces the memory allocated to the int data type. The
range, therefore, reduces accordingly.

• The long keyword increases the memory allocated to the int data type. The
range increases accordingly.

• The unsigned keyword specifies that only non-negative integers can be


stored inside the int data type.

• The signed keyword specifies that all positive, negative and zero integers
can be stored.

• Unless mentioned, the int data type is signed by default.


float data type
• This data type holds decimal numbers.

• Decimal numbers are those which contain an integer part and a fractional
part separated by a decimal point

• Ex: 19.23, -9.21

• The keyword "float" is used to declare the float data type.

• The format specifier is denoted by "%f"


What happens when we store an integer in
float variable
double data type
• This is also used to store decimal numbers.

• The keyword "double" is used to declare the double data type

• The format specifier is denoted by “%lf”


double data type

• The key difference between the float and the double data type is the
number of digits each can store after the decimal point and
therefore the memory allocated to both of them is different.

• The double data type has 15 decimal digits of precision while the
float data type has 6 decimal digits of precision
char data type
• It is used to store single character values

• Each character has an ASCII value associated with it. The keyword
“char” is used to declare the char data type.

• The format specifier for this data type is "%c“


char data type
• We can also have signed and unsigned type modifiers for the char
data type.

• The signed char data type has a range from -127 to 128.

• The unsigned data type has a range from 0 to 255.


void
• It is used if nothing is passed in the
function or the function doesn't
return anything.
Secondary data types
Secondary
Data types

User Derived
Defined Data types

Structure
Array

Union String

Typedef Pointer

Enum Functions
కొన్నన రోజులు (Research)

కొన్నన రోజుల తరువాత


1. 10 bores are not working – int bores = 10;

2. Pass percentage of school Let’s operate our


students are 30.26 kingdom

Father
3. Fight with king “SURBALI”

Dennis Ritchie

నాన్న నాకు కుుంచ ుం


సమయుం ఇవ్వుండి
SURBALI
🤠 Research🤠
C Grammar,
C Tokens,
Trigraph sequences,
Keywords,
Identifiers
etc

You might also like