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.

Slides:



Advertisements
Similar presentations
Variables in C Amir Haider Lecturer.
Advertisements

Etter/Ingber Engineering Problem Solving with C Fundamental Concepts Chapter 4 Modular Programming with Functions.
CSC141- Introduction to Computer Programming
Programming In C++ Spring Semester 2013 Lecture 12 Programming In C++, Lecture 12 By Umer Rana.
Programming and Data Structure
What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the.
1 Lecture 7  Fundamental data types in C  Data type conversion:  Automatic  Casting  Character processing  getchar()  putchar()  Macros on ctype.h.
CS1061 C Programming Lecture 16: Formatted I/0 A. O’Riordan, 2004.
1 Fundamental Data Types. 2 Declaration All variables must be declared before being used. –Tells the compiler to set aside an appropriate amount of space.
Chapter 9 Formatted Input/Output Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
1 Review of Chapter 6: The Fundamental Data Types.
C Programming for Embedded Systems. fig_06_00 Computer Layers Low-level hardware to high-level software (4GL: “domain-specific”, report-driven, e.g.)
Data Types.
C programming---basic 1 Introduction to C 2 C Fundamentals 3 Formatted Input/Output 4 Expression 5 Selection Statement 6 Loops 7 Basic Types 8 Arrays 9.
‘C’ LANGUAGE PRESENTATION.  C language was introduced by Dennis Ritchie..  It is a programming language, which can make a interaction between user and.
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.
Storage Classes.
Lecture No: 16. The scanf() function In C programming language, the scanf() function is used to read information from standard input device (keyboard).
Programming III SPRING 2015
Chapter 9 Formatted Input/Output. Objectives In this chapter, you will learn: –To understand input and output streams. –To be able to use all print formatting.
MAHENDRAN CHAPTER 6. Session Objectives Explain Type of Functions Discuss category of Functions Declaration & Prototypes Explain User Defined Functions.
By Sidhant Garg.  C was developed between by Dennis Ritchie at Bell Laboratories for use with the Unix Operating System.  Unlike previously.
C Tokens Identifiers Keywords Constants Operators Special symbols.
C-Language Keywords(C99)
8-1 Embedded Systems Fixed-Point Math and Other Optimizations.
C STRUCTURES. A FIRST C PROGRAM  #include  void main ( void )  { float height, width, area, wood_length ;  scanf ( "%f", &height ) ;  scanf ( "%f",
CISC105 – General Computer Science Class 9 – 07/03/2006.
GUIDED BY- A.S.MODI MADE BY- 1. SHWETA ALWANI 2. PRIYANKA.
Introduction to C Programming Chapter 2 : Data Input, Processing and Output.
Fundamentals of C and C++ Programming. EEL 3801 – Lotzi Bölöni Sub-Topics  Basic Program Structure  Variables - Types and Declarations  Basic Program.
CSCI 130 Chapter 3. Variables & Names Variable Declarations: –reserve a storage location in memory –identify the name of the variable –identify the type.
Dennis Ritchie 1972 AT & T Bell laboratories (American Telephone and Telegraph) USA 1www.gowreeswar.com.
Pointers: Basics. 2 What is a pointer? First of all, it is a variable, just like other variables you studied  So it has type, storage etc. Difference:
CSC141 Introduction to Computer Programming Teacher: AHMED MUMTAZ MUSTEHSAN Lecture - 6.
Chapter 7 C supports two fundamentally different kinds of numeric types: (a) integer types - whole numbers (1) signed (2) unsigned (b) floating types –
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee C Language Part 1.
CSI 3125, Preliminaries, page 1 Data Type, Variables.
Chapter2 Constants, Variables, and Data Types. 2.1 Introduction In this chapter, we will discuss –constants (integer, real, character, string, enum),symbolic.
Module B - Computation1/61 Module-B-Computation Variables Basic Memory Operations Expressions.
Silberschatz and Galvin  C Programming Language Kingdom of Saudi Arabia Ministry of Higher Education Al-Majma’ah University College of Education.
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
Gator Engineering Project 1 Grades released Re-grading –Within one week –TA: Fardad, or office hours: MW 2:00 – 4:00 PM TA Huiyuan’s office hour.
CMSC 104, Version 8/061L09VariablesInC.ppt Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement Reading.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
NOTE: C programs consist of functions one of which must be main. C programs consist of functions one of which must be main. Every C program begins executing.
7. BASIC TYPES. Systems of numeration Numeric Types C’s basic types include integer types and floating types. Integer types can be either signed or unsigned.
BASIC C PROGRAMMING LANGUAGE TUTORIAL infobizzs.com.
© Copyright by Deitel 1 Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple.
1 ENERGY 211 / CME 211 Lecture 3 September 26, 2008.
C++ Lesson 1.
User Interaction and Variables
7. BASIC TYPES.
TMF1414 Introduction to Programming
By: Syed Shahrukh Haider
Fundamental Data Types
C programming---basic
DATA HANDLING.
Lecture 13 Input/Output Files.
Introduction to CS Your First C Programs
פרטים נוספים בסילבוס של הקורס
פרטים נוספים בסילבוס של הקורס
Local Variables, Global Variables and Variable Scope
Fundamental Data Types
C Data Types and Variable
Variables in C Topics Naming Variables Declaring Variables
C Language B. DHIVYA 17PCA140 II MCA.
C Programming Lecture-17 Storage Classes
INTRODUCTION TO C.
Presentation transcript:

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 ( No. of bytes ) will be stored by the variable.

Types of data types. 1.Primary data types. 2.User-defined data types. 3.Derived data types. 4.Empty data set.

1. Primary Data Type 1.Integral Type 1.1. Character signed char unsigned char 1.2. Integer Signed type int short int long int Unsigned Type unsigned int unsigned short int unsigned long int 2. Floating Point Type 2.1. float 2.2. double 2.3. long double

Variable Type C has the following simple data types:

Basic Types Type (16 bit)Smallest ValueLargest Value short int-32,768(-2 15 )32,767( ) unsigned short int065,535( ) Int-32,76832,767 unsigned int065,535 long int-2,147,483,648(-2 31 )2,147,483,648( ) unsigned long int04,294,967,295

Basic Types Type (32 bit)Smallest ValueLargest Value short int-32,768(-2 15 )32,767( ) unsigned short int065,535( ) Int-2,147,483,648(-2 31 )2,147,483,648( ) unsigned int04,294,967,295 long int-2,147,483,648(-2 31 )2,147,483,648( ) unsigned long int04,294,967,295

Floating Types float single-precision floating-point double double-precision floating-point long double extended-precision floating-point TypeSmallest Positive Value Largest ValuePrecision float1.17* * digits double2.22* * digits double x; long double x; scanf(“%lf”, &x); scanf(“%Lf”, &x); printf(“%lf”, x); printf(“%Lf”, x);

2. User – Defined Data Type C supports a feature of “type definition” that allows user to define an identifier that would represent an existing data type. User – defined data type identifier can later be used to declare variables such as:  typedef  enum The general form for given above user – defined data type is as follows: typedef datatype identifier; enum identifier {value1,value2,…..valuen};

3. Derived Data Type C Compiler supports following derived data type: 1. Array 2. Function 3. Structure 4. Pointer

4. Empty Data Set The C Compiler supports the Empty data set which is mainly described in functions. The “void” is an Empty data set.

printf() and scanf() printf() is used for printing formatted output. scanf() is used for reading formatted input. Both have a list of arguments. control_string and other_arguments

Conversion Characters 13 Conversion Character Interpretation cCharacter ddecimal integer ffloating-point number ( float ) lffloating-point number ( double ) Lffloating-point number ( long double ) sstring

Type Conversion long double double float Unsigned long int long int unsigned int int

Type Conversion char c; short int s; int i; unsigned int u; long int l; unsigned long int ul; float f; double d; long double ld; i = i + c; /* c is converted to int */ i = i + s; /* s is converted to int */ u = u +i; /* i is converted to unsigned int */ l = l + u; /* u is converted to long int */ ul =ul + l; /* l is converted to unsigned long int */ f = f + ul; /* ul is converted to float */ d = d + f; /* f is converted to double */ ld = ld + d; /* d is converted to long double */

Casting ( type-name ) expression float f, frac_part; frac_part = f – (int) f; float quotient; int dividend, divisor; quotient = (float) dividend / divisor; short int i; int j = 1000; i = j * j; /* WRONG */

Storage Classes Every C variable has a characteristic is called its storage class. The Storage class defines two characteristics of the variable. – Lifetime – Visibility (Scope) Lifetime :- The lifetime of a variable is the length of time it retains a particular value. Visibility :- The visibility of a variable refers to which parts of a program will be able to recognize it. A variable may be visible in a block of function, a file, a group of files, or an entire program.

Storage Classes AutomaticExternalStaticRegister StorageMemory Register Default Initial value Garbage ValueZero Garbage value ScopeLocal to the block GlobalLocal to the block LifeTill the control remains in the block As long as the program’s execution doesn’t come to an end Value of variable persists between different function call Till the controls remains in the block