Data Type. A data type defines a set of values that a variable can store along with a set of operations that can be performed on that variable. Common.

Slides:



Advertisements
Similar presentations
C How to Program, 6/e © by Pearson Education, Inc. All Rights Reserved.
Advertisements

Data Types in C. Data Transformation Programs transform data from one form to another –Input data  Output data –Stimulus  Response Programming languages.
1 Structures. 2 User-Defined Types C provides facilities to define one’s own types. These may be a composite of basic types ( int, double, etc) and other.
C Structures Basics of structures Typedef. Data Hierarchy Byte –8 bits (ASCII character ‘A’ = ) Field –Group of characters (character string “Fred”)
Unions The storage referenced by a union variable can hold data of different types subject to the restriction that at any one time, the storage holds data.
Structures Spring 2013Programming and Data Structure1.
1 C++ Syntax and Semantics The Development Process.
Chapter 3: Beginning Problem Solving Concepts for the Computer Programming Computer Programming Skills /1436 Department of Computer Science.
1 Lecture 7  Fundamental data types in C  Data type conversion:  Automatic  Casting  Character processing  getchar()  putchar()  Macros on ctype.h.
Dale/Weems/Headington
CS1061 C Programming Lecture 4: Indentifiers and Integers A.O’Riordan, 2004.
1 Key Concepts:  Data types in C.  What is a variable?  Variable Declaration  Variable Initialization  Printf()  Scanf()  Working with numbers in.
Variables and constants Applications of Computer Programming in Earth Sciences Instructor: Dr. Cheng-Chien LiuCheng-Chien Liu Department of Earth Sciences.
Computer Science 1620 C++ - Basics. #include using namespace std; int main() { return 0; } A very basic C++ Program. When writing your first programs,
Data Types.
‘C’ LANGUAGE PRESENTATION.  C language was introduced by Dennis Ritchie..  It is a programming language, which can make a interaction between user and.
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)
Variables and Data Types
C Tokens Identifiers Keywords Constants Operators Special symbols.
Arrays in C++ Numeric Character. Structured Data Type A structured data type is a type that stores a collection of individual components with one variable.
C STRUCTURES. A FIRST C PROGRAM  #include  void main ( void )  { float height, width, area, wood_length ;  scanf ( "%f", &height ) ;  scanf ( "%f",
Data Types. Data types Data type tells the type of data, that you are going to store in memory. It gives the information to compiler that how much memory.
GUIDED BY- A.S.MODI MADE BY- 1. SHWETA ALWANI 2. PRIYANKA.
Structures in C++ UNIVERSITY OF THE PUNJAB (GUJRANWALA CAMPUS) 1 ADNAN BABAR MT14028 CR.
C++ Character Set It is set of Characters/digits/symbol which is valid in C++. Example – A-Z, (white space) C++ Character Set It is set of.
Dennis Ritchie 1972 AT & T Bell laboratories (American Telephone and Telegraph) USA 1www.gowreeswar.com.
Array, Structure and Union
Variables and Data Types.  Variable: Portion of memory for storing a determined value.  Could be numerical, could be character or sequence of characters.
CONSTANTS Constants are also known as literals in C. Constants are quantities whose values do not change during program execution. There are two types.
Data Type. Syntax Rules Recap keywords breakdoubleifsizeofvoid caseelseintstatic..... Identifiers not#me123th scanfprintf _idso_am_igedd007 Constant ‘a’‘+’
The Cn Language over view The Cn language strongly on ANSI C. So if you are familiar with ANCI it is not so tough to deal with Cn language. Basic Data.
Programming Fundamentals. Today’s Lecture The Conditional Operator Logical Operators Structures Enumerations.
 Structures are like arrays except that they allow many variables of different types grouped together under the same name. For example you can create.
Data Types Declarations Expressions Data storage C++ Basics.
Data Structure and c K.S.Prabhu Lecturer All Deaf Educational Technology.
1 C Language Structures. 2 Topics Concept of a structure Concept of a structure Structures in c Structures in c Structure declaration Structure declaration.
CSCI 3133 Programming with C Instructor: Bindra Shrestha University of Houston – Clear Lake.
Chapter2 Constants, Variables, and Data Types. 2.1 Introduction In this chapter, we will discuss –constants (integer, real, character, string, enum),symbolic.
Data Types Always data types will decide which type of information we are storing into variables In C programming language we are having 3 types of basic.
Structure A collection of values (members) struct date{ int day; char month[10]; int year; }; Declare a structure variable struct date today; struct struct_name.
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
 constant represented by a name, just like a variable, but whose value cannot be changed  The const keyword precedes the type, name, and initialization.
CMSC 104, Version 8/061L09VariablesInC.ppt Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement Reading.
 Data Type is a basic classification which identifies different types of data.  Data Types helps in: › Determining the possible values of a variable.
1 CSC103: Introduction to Computer and Programming Lecture No 17.
Chapter 6. Character String Types It is one in which the values consists of sequences of characters. How to Define a variable contain a string? In a programming.
Objectives A data type is  A set of values AND  A set of operations on those values A data type is used to  Identify the type of a variable when the.
Chapter 11 Structures, Unions and Typedef 11.1 Structures Structures allow us to group related data items of different types under a common name. The individual.
BASIC C PROGRAMMING LANGUAGE TUTORIAL infobizzs.com.
Java Programming Language Lecture27- An Introduction.
Lecture 4 Monday Sept 9, Variables and Data Types ►A►A►A►A variable is simply a name given by the programmer that is used to refer to computer storage.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
User Interaction and Variables
Data types Data types Basic types
CSE101-Lec#3 Components of C Identifiers and Keywords Data types.
Variables ,Data Types and Constants
DATA HANDLING.
Variables In programming, we often need to have places to store data. These receptacles are called variables. They are called that because they can change.
Advanced Programming Basics
Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Character Set Uppercase Alphabets A,
Java Tutotrial for [NLP-AI] 2
Windows Programming Lecture 04
Chapter 1: Introduction to Data Structures(8M)
Programming Language C Language.
C Data Types and Variable
Variables in C Topics Naming Variables Declaring Variables
C Language B. DHIVYA 17PCA140 II MCA.
C Programming Lecture-3 Keywords, Datatypes, Constants & Variables
Variables and Constants
Structures, Unions, and Enumerations
Presentation transcript:

Data Type

A data type defines a set of values that a variable can store along with a set of operations that can be performed on that variable. Common data types are integer, character, and real.

Data Type Data Types

Data Type

Basic Data type(Primary, fundamental) Integers, Character and Floating point Integer Singed typeUnsigned type intunsigned int short intunsigned short int long intunsigned long int Character Signed char Unsigned char Floating Point floatdoublelong double Primary Data type

Data Type Basic Data type(Primary, fundamental) Integers Signed and unsigned types Signed– can store + and –ve integers Unsigned– can store only +ve integers Integer Singed typeUnsigned type intunsigned int short intunsigned short int long intunsigned long int

Data Type Basic Data type(Primary, fundamental) Signed type integers int :- integers are whole numbers, capable to storing numeric value without decimal places. any number in the range to It occupies 2 bytes of memory Long int :- required 4 bytes of memory. Value range from to Long int variable can declare long int a,b; or long a;

Data Type Basic Data type(Primary, fundamental) Signed type integers Short integers :- need less space in memory (same as int) Short int variable can delare short int a; or int a;( both are same)

Data Type Basic Data type(Primary, fundamental) Unsigned integers unsigned integers :- some time if we know in advanced, the value stored in an integer variable is always be +ve. Such situations we can declared the variable as unsigned int The range permissible integer value will shift from 0 to ie double the size of int Unsigned integer variable can declare unsigned int a; or unsigned a;( both are same)

Data Type Basic Data type(Primary, fundamental) Unsigned integers unsigned short integers :- same as unsigned int unsigned long integers :- Range 0 to (double size of long int) Unsigned long integer variable can declare unsigned long int a;

Data Type Basic Data type(Primary, fundamental) Characters Signed and unsigned types Both occupy 1 byte of memory But having different range Signed char is same as ordinary char and has range to 127 Unsigned char range from 0 to 255 Example cnsigned char a; char a; Character Signed char Unsigned char

Data Type Basic Data type(Primary, fundamental) Floating point A float variable occupy 4 bytes of memory Range from 3.4E-38 to 3.4E+38 Double occupy 8 bytes of memory Range from 1.7E-308 to 1.7E+308 Long double occupy 10 bytes of memory Range from 3.4E-4932 to 3.4E+4932 Floating Point floatdoublelong double

Data Type Typesize (bytes)Range char1 127 to -128 unsigned char1 0 to 255 int to unsigned int2 0 to short int to long int to unsigned long int4 0 to float4 3.4E-38 to 3.4E+38 double8 1.7E-308 to 1.7E+308 long double10 3.4E-4932 to 3.4E+4932

Data Type User Defined Data Type Type Definition Enumerated datatype Structure Union User Defined Data type Type Definition Enumerated datatype Structure Union

Data Type User Defined Data Type Type Definition Allows user to define an identifier that would represent an existing data type This identifier can later used to declared variables syntax:-- Eg: typedef int integet; integer a;

Data Type User Defined Data Type Enumerated Allows user to declare variables can have one value enclosed within braces. Way of attaching name to numbers syntax:-- Eg: enum sex{male,female}; Then value of male=0 and female=1

Data Type User Defined Data Type Structure A structure is a collection of one or more variables, possibly of different types, grouped together under a single name A structure is defined by the keyword struct followed by a set of variables enclosed in braces. Consider the following structure to represent a person’s details. struct Personnel { char name[100]; int age; double height; }; The variables name, age and height are called members of the structure type Personnel.

Data Type User Defined Data Type Structure There are two ways to define variables of a particular structure type. 1.Declare them at the structure definition. struct Personnel { char name[100]; int age; double height; } p1, p2, p3; /* Define 3 variables */ 2.Define the variables at some point after the structure definition. struct Personnel p1, p2, p3; /* Define 3 variables */

Data Type User Defined Data Type Union A union is a collection of one or more variables, possibly of different types, grouped together under a single name A union is defined by the keyword union followed by a set of variables enclosed in braces. Consider the following union to represent a person’s details. union Personnel { char name[100]; int age; double height; }; The variables name, age and height are called members of the union type Personnel.

Data Type User Defined Data Type union There are two ways to define variables of a particular union type. 1.Declare them at the union definition. union Personnel { char name[100]; int age; double height; } p1, p2, p3; /* Define 3 variables */ 2.Define the variables at some point after the union definition. union Personnel p1, p2, p3; /* Define 3 variables */

Data Type Derived datatype Array… Functions… Pointers… Reference… Derived datatype Array Function Pointers Reference

Data Type Empty data type void

Escape Sequence Escape sequence is used in the printf() function to do something to the output.