C Data Types and Variable

Slides:



Advertisements
Similar presentations
Introduction to C Systems Programming Concepts. Introduction to C A simple C Program A simple C Program –Variable Declarations –printf ( ) Compiling and.
Advertisements

Overview of programming in C C is a fast, efficient, flexible programming language Paradigm: C is procedural (like Fortran, Pascal), not object oriented.
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
IT 325 OPERATING SYSTEM C programming language. Why use C instead of Java Intermediate-level language:  Low-level features like bit operations  High-level.
Semantic Analysis Chapter 6. Two Flavors  Static (done during compile time) –C –Ada  Dynamic (done during run time) –LISP –Smalltalk  Optimization.
Making Choices in C if/else statement logical operators break and continue statements switch statement the conditional operator.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 5 Types Types are the leaven of computer programming;
Structure of a C program
1 Key Concepts:  Data types in C.  What is a variable?  Variable Declaration  Variable Initialization  Printf()  Scanf()  Working with numbers in.
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.
Lecture No: 16. The scanf() function In C programming language, the scanf() function is used to read information from standard input device (keyboard).
By: Mr. Baha Hanene Chapter 3. Learning Outcomes We will cover the learning outcome 02 in this chapter i.e. Use basic data-types and input / output in.
Variables and Data Types
C Tokens Identifiers Keywords Constants Operators Special symbols.
Outline Character Strings Variables and Assignment Primitive Data Types Expressions Data Conversion Interactive Programs Graphics Applets Drawing Shapes.
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.
Copyright 2005, The Ohio State University 1 Pointers, Dynamic Data, and Reference Types Review on Pointers Reference Variables Dynamic Memory Allocation.
Computer Organization and Design Pointers, Arrays and Strings in C Montek Singh Sep 18, 2015 Lab 5 supplement.
How to execute Program structure Variables name, keywords, binding, scope, lifetime Data types – type system – primitives, strings, arrays, hashes – pointers/references.
1.2 Primitive Data Types and Variables
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.
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.
 Data Type is a basic classification which identifies different types of data.  Data Types helps in: › Determining the possible values of a variable.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Arrays Outline 6.1Introduction 6.2Arrays 6.3Declaring.
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.
1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,
USER INTERACTION AND VARIABLES Tarik Booker CS 290 California State University, Los Angeles.
C LANGUAGE UNIT 3. UNIT 3 Arrays Arrays – The concept of array – Defining arrays – Initializing arrays.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Overview Working directly with memory locations is beneficial. In C, pointers allow you to: change values passed as arguments to functions work directly.
Computer Organization and Design Pointers, Arrays and Strings in C
User Interaction and Variables
Type Checking Generalizes the concept of operands and operators to include subprograms and assignments Type checking is the activity of ensuring that the.
Chapter 6: Data Types Lectures # 10.
Revision Lecture
Getting Started with C.
BY GAWARE S.R. COMPUTER SCI. DEPARTMENT
Lecture Note Set 1 Thursday 12-May-05
By: Syed Shahrukh Haider
OUTPUT STATEMENTS GC 201.
Variables ,Data Types and Constants
DATA HANDLING.
Complex Data Types One very important measure of the “goodness” of a PL is the capability of its data types to model the problem space variables Design.
2008/10/01: Lecture 8 CMSC 104, Section 0101 John Y. Park
CMSC 104, Section 4 Richard Chang
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.
An Introduction to Java – Part I, language basics
Chapter 9 - Arrays Outline 6.1 Introduction 6.2 Arrays
Variables in C Topics Naming Variables Declaring Variables
Chapter 2: Java Fundamentals
Variables in C Topics Naming Variables Declaring Variables
Local Variables, Global Variables and Variable Scope
C Storage classes.
Semantic Analysis Chapter 6.
Conversion Check your class notes and given examples at class.
C Programming Lecture-8 Pointers and Memory Management
Java Basics Data Types in Java.
Module 2 Variables, Data Types and Arithmetic
Type Systems Terms to learn about types: Related concepts: Type
Variables in C Topics Naming Variables Declaring Variables
2008/10/01: Lecture 8 CMSC 104, Section 0101 John Y. Park
Variables in C Topics Naming Variables Declaring Variables
C Programming Lecture-3 Keywords, Datatypes, Constants & Variables
Variables in C Topics Naming Variables Declaring Variables
Variables and Constants
Lecture 7: Types (Revised based on the Tucker’s slides) 10/4/2019
Variables in C Topics Naming Variables Declaring Variables
Getting Started With Coding
Presentation transcript:

C Data Types and Variable

Definition Data types are declarations for memory locations or variables that determine the characteristics of the data that may be stored and the methods (operations) of processing that are permitted involving them Example: Integer, float, character Before using variable it should be declared along with its datatype. Variable declaration syntax: Datatype variable_name

Static vs. Dynamic Typing First, what does strongly typed mean? Prevents invalid operations on a type Statically typed: strongly typed and type checks can be performed at compile time Ada, Pascal: almost all type checking done at compile time, with just a few exceptions C, C++, Java, Ocaml Dynamically typed: type checking is delayed until run time Scheme, Smalltalk, Perl

Types: Primitive Derived User defined Void

Basic Datatype Size of these types on CLEAR machines: Only really four basic types: char int (short, long, long long, unsigned) float double Size of these types on CLEAR machines: Size Varies from machine to machine

All datatype

Assignment A variable can be given value by means of assignment Assignment operator (=) is used for assignment Example: int x; x=5;

Initialization Values are NOT initialized during declaration by default in c If not initialized it may contain garbage value So better to initilialize during declaration Ex: int x=0; float product=1;

Display value of variable printf() function can be used to display value of variable Format specifier is compulsory to use Example printf(“value of x is %d”, x); printf(“y=%f”,y);

Getting value from user Commonly used function to get value for use is scanf()