data types in c programming language in detail

atulk4360 50 views 14 slides Nov 26, 2024
Slide 1
Slide 1 of 14
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14

About This Presentation

data types in c language


Slide Content

DATA TYPES IN C PROGRAMMING PRESENTED BY- AASHU PATEL

What is Data Type? A Data type is a type of data . Data type is data storage format that can contain a specific type or range of values. Data types in c refers to an extensive system used for declaring variable for function of different types. The type of variable determines how much space it occupies in storage and how the bit pattern stored in interpreted.

A Data Type Is Used To- Identify the type of a variable when the variable is declared. Identify the type of the return value of a function. Identify the type of a parameter expected by a function.

Data types in c Data types in c Primary Derived User Defined Integer Real Character Void Arrays Pointers Structure Union Enumeration Typedef

Primary data type These are fundamental or basic data type in c namely Integer Real Character Void

Integer Data type Integer are used to store whole number Type Size(bytes) Range Format specifier int or signed int 2 -32,768 to +32767 %d Unsigned int 2 0 to 65535 %d long int or signed long int 4 -2,147,483 to +2,147,483,647 %d Unsigned long int 4 0 to 4,294,967,295 %lu

2. Real Data Type Floating types are used to store real numbers. Type Size(bytes) Range Format specifiers float 4 3.4X10 -38 to 3.4X10+38 %f double 8 1.7X10-308 to 1.7X10+308 %if long double 10 3.4X10-4932 to 3.4X10+4932 %Lf

3. Character Data Type Character types are used to store character value. Type Size(bytes) Range Format specifiers Char or signed char 1 -128 to 127 %c Unsigned char 1 0 to 255 %c

4. Void Data Type Void type means no value. This is usually used to specify the type of function which returns nothing by defining in front of main() or any other function and as blank arguments within functional backets. For example- 1. void main() 2.void main(void)

B. Derived Data Type Array: An array in c language is a collection of similar data-type,means an array can hold value of a particular data type for which it has been declared. Arrays can be created from any of the C data-types int. Example: int a[4]={10,20,30,40}; Index/position a[0] a[1] a[2] a[3] Values Address in memory 1002 1004 1006 Pointer : C pointer is a special variable that can be used to store address of another variable. 10 20 30 40

C. User Defined 1. Structure Data Type C structure is a collection of different data types which are grouped together and each element in a C structure is called member. Example : Struct student{ int roll no; char name[20]; char city[20]; } 2.Union Data Type It is a package of variables of different types under a single name. “union” keyword is used to define a structure. The highest bytes of data types will occupy the memory. e.g. union student { int roll no; char name[10]; float per; }std; Structure student will occupy 4 bytes in memory as float is the highest data among int and char.

3 . Enumerated Data Type (Enum) Enumerated data type is a user defined data type having finite set of enumeration constant. The keyword “enum” is used to create enumerated data type. Enumeration data type consists of named integer constants as a list . It start with 0 (zero) by default and value is incremented by 1 for the sequential identifiers in the list. Syntax: Enum [data type] {const1,const2…constn} Enum example in C: enum month {Jan, Feb, Mar};or/* Jan,Feb and Mar variables will be assigned to 0,1 and 2 respectively by default */ enum month {Jan = 1, Feb, Mar};/*Feb and Mar variables will be assigned to 2 and 3 respectively by default */ Enum month {Jan = 20, Feb, Mar};/* Jan is assigned to 20. Feb and Mar variables will be assigned to 21 and 22 respectively by default */

4. Typedef Data Type It is used to create new data type. But it is commonly used to change existing data type with another name. Syntax: typedef [data_type]new_data_type; Example: typedef int integer; integer roll_no;

THANK YOU FOR YOUR ATTENTION
Tags