The fundamental data type 제 4 주 강의. Declarations, Expressions, and Assignments Declaring the type of a variable  set an appropriate amount of space in.

Slides:



Advertisements
Similar presentations
1 Lecture 7  Fundamental data types in C  Data type conversion:  Automatic  Casting  Character processing  getchar()  putchar()  Macros on ctype.h.
Advertisements

Programming Declarations. COMP102 Prog. Fundamentals I: Declarations/ Slide 2 General form of a C++ program // Program description #include directives.
1 9/10/07CS150 Introduction to Computer Science 1 Data Types Section 2.7 – 2.12 CS 150 Introduction to Computer Science I.
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.
1 9/8/08CS150 Introduction to Computer Science 1 Data Types Section 2.7 – 2.12 CS 150 Introduction to Computer Science I.
Fundamental data types
CS1061 C Programming Lecture 4: Indentifiers and Integers A.O’Riordan, 2004.
C programming an Introduction. Types There are only a few basic data types in C. char a character int an integer, in the range -32,767 to 32,767 long.
CS150 Introduction to Computer Science 1
Variables and constants Applications of Computer Programming in Earth Sciences Instructor: Dr. Cheng-Chien LiuCheng-Chien Liu Department of Earth Sciences.
1 Review of Chapter 6: The Fundamental Data Types.
Introduction to programming Language C, Data Types, Variables, Constants. Basics of C –Every program consists of one or more functions and must have main.
CSC 125 Introduction to C++ Programming Chapter 2 Introduction to C++
CSCI 1100/1202 January 16, Why do we need variables? To store intermediate results in a long computation. To store a value that is used more than.
C How to Program, 6/e © by Pearson Education, Inc. All Rights Reserved.
C Programming Lecture 4 : Variables , Data Types
3. The Nuts and Bolts of C++ Computer Programming 3. The Nuts and Bolts of C++ 1 Learning the C++ language 3. The Nuts and Bolts of C++ (4)
C Tokens Identifiers Keywords Constants Operators Special symbols.
C-Language Keywords(C99)
Constants in C A Presentation On Department of Computer & Information Technology, M.S.P.V.L. Polytechnic College, Pavoorchatram.
CSE 425: Target Machine Architecture Target Machine Details Many architectures can be similar in overall structure –E.g., Von Neumann with CISC instruction.
Instructor: Alexander Stoytchev CprE 185: Intro to Problem Solving (using C)
Fundamental Data Types, Operators and Expressions Kernighan/Ritchie: Kelley/Pohl: Chapter 2 Chapter 2, 3.
Data Type. Syntax Rules Recap keywords breakdoubleifsizeofvoid caseelseintstatic..... Identifiers not#me123th scanfprintf _idso_am_igedd007 Constant ‘a’‘+’
CS115 FALL Senem KUMOVA-METİN1 The Fundamental Data Types CHAPTER 3.
Data Types Declarations Expressions Data storage C++ Basics.
C++ Basics Tutorial 5 Constants. Topics Covered Literal Constants Defined Constants Declared Constants.
Constants, Variables and Data types in C The C character Set A character denotes any alphabet, digit or special symbol used to represent information.
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.
Programming Fundamentals
Tokens in C  Keywords  These are reserved words of the C language. For example int, float, if, else, for, while etc.  Identifiers  An Identifier is.
Objects Variables and Constants. Our Scuba Problem #include // cin, cout, > using namespace std; int main() { const double FEET_PER_ATM = 33.0, LBS_PER_SQ_IN_PER_ATM.
Types Chapter 2. C++ An Introduction to Computing, 3rd ed. 2 Objectives Observe types provided by C++ Literals of these types Explain syntax rules for.
Powerpoint Templates Page 1 Programming in C/C++ PS04CINS02.
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.
CS113 Introduction to C Instructor: Ioannis A. Vetsikas Lecture 5 : September 4.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
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.
BIL 104E Introduction to Scientific and Engineering Computing Lecture 2.
Introduction to ‘c’ language
Tokens in C Keywords Identifiers Constants
Wel come.
7. BASIC TYPES.
ITEC113 Algorithms and Programming Techniques
Fundamental Data Types
INTRODUCTION c is a general purpose language which is very closely associated with UNIX for which it was developed in Bell Laboratories. Most of the programs.
Data Type.
ASST. Prof. Dr. Hacer Yalım Keleş
CprE 185: Intro to Problem Solving (using C)
Introduction to the C Language
C Program Design Data Types
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.
Data Type.
Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Character Set Uppercase Alphabets A,
C++ Basics.
Escape Sequences Some Java escape sequences: See Roses.java (page 68)
Variables in C Topics Naming Variables Declaring Variables
Basics of ‘C’.
CS111 Computer Programming
Lectures on Numerical Methods
Basic Types Chapter 7 Copyright © 2008 W. W. Norton & Company.
Pointers Pointers point to memory locations
Fundamental Data Types
ECE 103 Engineering Programming Chapter 8 Data Types and Constants
What Actions Do We Have Part 1
Data Type.
Variables in C Topics Naming Variables Declaring Variables
Programming Fundamental-1
Variables in C Topics Naming Variables Declaring Variables
Presentation transcript:

The fundamental data type 제 4 주 강의

Declarations, Expressions, and Assignments Declaring the type of a variable  set an appropriate amount of space in memory by a compiler  deciding appropriate operations  checking invalid operations and operands (686page 참고 )

Expressions Meaningful combinations of constants, variables, operators, and function calls a+b 5.0*x – tan(9.0/x) Page 689 참고

Assignments variable = expr ; Page 689 참고 숙제 ::: a=b=c+d=e  이것이 정상적인 assignment statement 임을 문법을 참고로 증명하라 !!! 적용된 문법을 보일 것

The fundamental data types Declaration ::= type identifier {, identifier} 0+ ;

Long form Fundamental data types: long form char signed char unsigned char signed short int signed int signed long unsigned short int unsigned int unsigned long float double long double fundamental types array, pointer, structure ::: derived types

Widely used form Fundamental data types: long form char signed char unsigned char short int long unsigned short unsigned unsigned long float double long double ‘ int ’ can be omitted

Functionality Fundamental types grouped by functionality Integral types Char signed char unsigned char Short int long Unsigned short unsigned unsigned long Floating types Float double long double Arithmetic types Integral types + Floating types

3.3 Characters and the Data Type char getchar(), putchar() 8bits (2 8 =256) 대문자, 소문자, 숫자, 구두점, 특수문자 White space characters 는 포함 제어문자는 제외 ASCII, EBCDIC

ASCII Some character constants and their corresponding integer values Character constants Corresponding values Character constants Corresponding values Character constants Corresponding values Character constants Corresponding values ‘ a ’ ‘ b ’ ‘ c ’ … ‘ z ’ … 112 ‘ A ’ ‘ B ’ ‘ C ’ … ‘ Z ’ … 90 ‘ 0 ’ ‘ 1 ’ ‘ 2 ’ … ‘ 9 ’ … 57 ‘ & ’ ‘ * ’ ‘ + ’

Special characters Special Characters Name of characterWritten in CInteger value Alert Backslash Backspace Carriage return Double quote Formfeed Horizontal tab Newline Null character Single quote Vertical tab Question mark \a \\ \b \r \ ” \f \t \n \0 \ ’ \v \?

출력 printf( “ %c ”, ‘ \a ’ ) ;  putchar( ‘ \a ’ ) printf( “ %\ ” abc\ ”” ) ;  “ abc ” printf( “ %cabc%c ”, ‘ \ ’’, ’ \ ’’ ) ;  ‘ abc ’

출력 예 int c; int i; for (i= ‘ a ’ ; i<= ‘ z ’ ;++i) printf( “ %c ”,i); /* abc … z */ for (c=65; c<=90;++c) printf( “ %c ”,c); /* ABC … Z */ for (c= ‘ 0 ’ ; c<= ‘ 9 ’ ;++c) printf( “ %d ”,c); /* … 57 */ (2) == 97 == ‘ a ’

Integer 32bits : -2 31, … -1, 0, 1, … … bits : -2 15, … -1, 0, 1, … … N min_int ≤ i ≤ N max_int

Short, long, unsigned short  16bits long  32bits unsigned  32bits 기계 : N max_unsigned = ( 일부시스템 ) 16bits 기계 : N max_unsigned = 2 16 – 1 ( 일부시스템 ) =  16bits 기계  32000(short), 33000(long)

상수표현 방법 Combining long and unsigned SuffixTypeExample u or Uunsigned37U l or Llong37L ul or ULunsigned37UL

The floating types Float, double, long double Combining float and unsigned SuffixTypeExample f or Ffloat3.7F l or Llong double3.7L

Floating point 값의 표현 Precision, range float  0.d 1 d 2 … d 6 x 10 n (-38 ≤ n≤ 38) double  0.d 1 d 2 … d 15 x 10 n (-308 ≤ n≤ 308)  x ( 유효숫자 15) long double  long 으로 구현

The use of typedef typedef char uppercase typedef int INCHES, FEET; typedef unsigned long size_t; uppercase u; INCHES length, width;

The sizeof Operator sizeof(object) sizeof(char)  1 sizeof(char) ≤ sizeof(short) ≤ sizeof(int) ≤ sizeof(long) sizeof(signed) = sizeof(unsigned) = sizeof(int) sizeof(float) ≤ sizeof(double) ≤ sizeof(long double)