0% found this document useful (0 votes)
9 views15 pages

Data Types

The document discusses various C programming data types including fundamental types like int, char, float, and double. It also covers derived types like arrays and pointers, as well as user-defined types such as enums, unions, and structures. For each type, it provides details on memory usage, value ranges, and keywords. It explains how data types specify the type of value and provide instructions to the compiler for memory allocation and input/output formatting.

Uploaded by

Yonith Jamad
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)
9 views15 pages

Data Types

The document discusses various C programming data types including fundamental types like int, char, float, and double. It also covers derived types like arrays and pointers, as well as user-defined types such as enums, unions, and structures. For each type, it provides details on memory usage, value ranges, and keywords. It explains how data types specify the type of value and provide instructions to the compiler for memory allocation and input/output formatting.

Uploaded by

Yonith Jamad
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/ 15

Programming in C

Data Types

1
Content
• Introduction
• Types
• Void
• Character
• Integer
• Float
• Double
• Short
• Long
• Signed and Unsigned
• Derived
• User Defined
• Enumerate

Programming in C
Introduction
• The type of valued used.
• Instruction to compiler.
• Need to allocate memory.
• Associated with format specifier.
• Format specifiers are needed to read and write value of particular type.
• Format specifiers are preceded with percentage (%)

Programming in C
Types

Programming in C
Void Type
• Void means nothing.
• Used when identifier is not belong to any type.
• Used in function return type.
• Keyword is ‘void’

Programming in C
Character Type
• Handle single character value. Character char %c

• Value must be covered in single quotes (‘a’).


• Value ranges from -127 to +128.
• Keyword is ‘char’
• Character identifier can be assigned a numeric value in given range.
• ASCII value of character is handled.

Programming in C
Integer Type
• Numerical Data type. Integer int %d

• Memory allocated is 4 bytes


• Value ranges from -2,147,483,648 to 2,147,483,647
• The keyword used is ‘int’
• Used to store only positive numbers by using keyword ‘unsigned’ (0 to
65,535)

Programming in C
Float Type
• Numerical decimal values. Float float %f

• Memory allocated is 4 bytes


• Keyword is ‘float’

Programming in C
Double Type
• Numeric real numbers. Double double %lf

• Memory allocated is 8 bytes.


• Keyword is ‘double’

Programming in C
Short type
• Used to store shorter range of value. Data Type Keyword Format
Specifier
• Combined with Integer data type. Short Integer short int %hd

• Short Integer is allocated 2 bytes of memory.


• Short Integer ranges with in -32,768 to 32,767.
• The keyword is ‘short’

10

Programming in C
Long type
• Increase the size of type.
Data Type Keyword Format
• Long is combined with Integer Specifier
and Double Type. Long Integer long int %ld
• Long Integer allocated 4 byte Long Long Integer long long int %lld
as like default integer. Long Double long double %Ld

• Long Double allocated 16


bytes, double the time of
default double.
11

Programming in C
Signed or Unsigned Type
• Both negative and positive values are allowed Data Type Keyword Format
by default. Specifier
• Default sing is positive if no sign is specified Unsigned Short unsigned short int %hu
in value.
Integer
• Negative Sign should be given explicitly. Unsigned Integer unsigned int %u
• The keyword is ‘signed’ to have both positive Unsigned Long unsigned long int %lu
and negative value.
Integer
• Unsigned is used to restrict only with positive
values.
• The keyword is ‘unsigned’
• Combined with Character, Integer and Short
type 12

Programming in C
Derived Data type
• Derived from basic data type.
• Group more than one value in single identifier.
• Array
• Pointer

13

Programming in C
User Defined Data Type
• New data type
• Formed by grouping basic data type.
• Enumerate
• Union
• Structure

14

Programming in C
Enumerate Data Type
• User defined data type.
• Groups more than one constants.
• Assign name to integral constant.
• Default value of first integral constant is 0.
• Make easy to refer the value.
• The keyword used is ‘enum’
• Syntax
• enum Enumerate_Name{Const1, Const2…};
• enum Enumerat_Name{Const1=10, Const2…};
15

Programming in C

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy