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

Datatype Const Keyword

Uploaded by

21l121
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)
7 views

Datatype Const Keyword

Uploaded by

21l121
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/ 11

Recall

• Structure of a C Program
• Six Sections
• Documentation, Preprocessor Directives,
Definition, Global Declaration, Main function,
User defined function
• First C Program
• Compilation and Execution

4/30/2022 C.P.Shabariram 1
BASICS

• Programming paradigms
• Applications of C
Language
BASICS • Structure of C program
• Data Types & Constants
FILE ARRAYS & • Keywords &Operators
PROCESSING STRINGS • Expressions
• Input/Output statement
• Assignment statements
• Decision making
statements
STRUCTURE FUNCTIONS • Looping statements
& UNION & POINTERS • Preprocessor directives
• Compilation process
Tokens in C
• Tokens are the basic building blocks in C
Language

4/30/2022 C.P.Shabariram 3
Keywords
• Reserved word. 32 keywords in the C
language. Don’t use it as a variable name
auto double int struct
break else long switch
case enum register typedef
char extern return union
const float short unsigned
continue for signed void
default goto sizeof volatile
do if static while

4/30/2022 C.P.Shabariram 4
Character set in C
• set of all the valid characters that we can use
in the source program
Type of Character Characters
Alphabets a to z (Lowercase) A to Z (Uppercase)

Digits 0 to 9
Special `~@!$#^*%&()[]{}<>+=_–|/\;:‘“,.?
Characters
White Spaces \b Blank Spaces, \r Carriage Return, \t Tab, \n New
Line

4/30/2022 C.P.Shabariram 5
Identifiers
• Used for naming variables, functions, arrays,
structures, etc.
• Variable is defined as name given to memory
location.
• Example:
int a;
void display(){}
int ar[100];
struct node{}

4/30/2022 C.P.Shabariram 6
Rules for constructing Identifiers
• The first character of an identifier should be either an
alphabet or an underscore, and then it can be followed by any
of the character, digit or underscore.
• It should not begin with any numerical digit.
• Identifiers are case sensitive.
• Commas or blank spaces cannot be specified within an
identifier.
• Keywords cannot be represented as an identifier.
• The length of the identifiers should not be more than 31
characters.
• Identifiers should be meaningful, short, and easy to read.
4/30/2022 C.P.Shabariram 7
Data Types
• C language supports both signed and unsigned value.
• The memory size of the data types depends on
operating system (32 or 64-bit)
Data Types Memory Size Range
char 1 byte −128 to 127
signed char 1 byte −128 to 127
unsigned char 1 byte 0 to 255
short 2 bytes −32,768 to 32,767
signed short 2 bytes −32,768 to 32,767
unsigned short 2 bytes 0 to 65,535
int 2 bytes −32,768 to 32,767
4/30/2022 C.P.Shabariram 8
Data Types
Data Types Memory Size Range
signed int 2 bytes −32,768 to 32,767
unsigned int 2 bytes 0 to 65,535
short int 2 bytes −32,768 to 32,767
signed short int 2 bytes −32,768 to 32,767
unsigned short int 2 bytes 0 to 65,535
long int 4 bytes -2,147,483,648 to 2,147,483,647
signed long int 4 bytes -2,147,483,648 to 2,147,483,647
unsigned long int 4 bytes 0 to 4,294,967,295
float 4 bytes 3.4E-38 to 3.4E+38
double 8 bytes 1.7E-308 to 1.7E+308
long double 10 bytes 3.4E-4932 to 1.1E+4932

4/30/2022 C.P.Shabariram 9
Variables
• Meaningful name given to a data storage location in computer memory.
– Numeric variable : to store integer / floating point values
– Character variable : to store a single character
• Declaration:
– int reg_no;
– float cgpa;
– char grade;
• Initialization
– reg_no = 12;
– cgpa = 9.6;
– grade = ‘A’;

4/30/2022 C.P.Shabariram 10
Constants
• Identifiers whose values do not change
• Explicit data value specified by the programmer

Constants

Floating Point
Integer type Character type String type
type

12,12u or 12U, 0.02 , 0.02f or


12l or 12L, 012, 0.02F, 0.02L, ‘c’,’s’,’3’,’2’,’5’,’1’ “cs3251”
0X12 2e-2 or 2E-2

4/30/2022 C.P.Shabariram 11

You might also like