1 / 8

Data Type and Variable

Data Type and Variable. 2012/10/08 NCTU CS. Outline. Data Type Variable Arithmetic Practice Time. Data Type (1/2). Boolean( bool ) true  as 1, false as 0 Character( char ) Character, i.e. ‘A ’ Integer( short , int , long ) Integer values, i.e. 4,-10,0

naif
Download Presentation

Data Type and Variable

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Data Type and Variable 2012/10/08 NCTU CS

  2. Outline • Data Type • Variable • Arithmetic • Practice Time

  3. Data Type (1/2) • Boolean(bool) • true as 1, false as 0 • Character(char) • Character, i.e. ‘A’ • Integer(short , int , long) • Integer values, i.e. 4,-10,0 • Floating point(float , double , long double) • Real numbers, i.e. 0.000001

  4. Data Type (2/2) • Size • The actual size varies by implementation. • In Visual studio 2010 e.g. printf("%d\n", sizeof(float));

  5. Variable int myStudentID = 1234567 ; Value Data type Variable name

  6. Arithmetic(1/2) firstInt • Reads 123 from standard input stream. Stores 123 to firstInt

  7. Arithmetic(2/2)

  8. Practice Time • Write a program to calculate s = [(x+y) * f] – 5 You need to use prompt e.g. p.s. Don’t forget #include <stdio.h>

More Related