tailieunhanh - Computational Physics - M. Jensen Episode 1 Part 2

Tham khảo tài liệu 'computational physics - m. jensen episode 1 part 2', kỹ thuật - công nghệ, cơ khí - chế tạo máy phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Chapter 2 Introduction to C C and Fortran 90 95 Getting started In all programming languages we encounter data entities such as constants variables results of evaluations of functions etc. Common to these objects is that they can be represented through the type concept. There are intrinsic types and derived types. Intrinsic types are provided by the programming language whereas derived types are provided by the programmer. If one specifies the type to be . INTEGER KIND 2 for Fortran 90 951 or short int int in C C the programmer selects a particular date type with 2 bytes 16 bits for every item of the class INTEGER KIND 2 or mt. Intrinsic types come in two classes numerical like integer real or complex and non-numeric as logical and character . The general form for declaring variables is . and the following table lists the standard variable declarations of C C and Fortran 90 95 note well that there may compiler and machine differences from the table below An important aspect when declaring variables is their region of validity. Inside a function we define a a variable through the expression int var or INTEGER var . The question is whether this variable is available in other functions as well moreover where is var initialized and finally if we call the function where it is declared is the value conserved from one call to the other Both C C and Fortran 90 95 operate with several types of variables and the answers to these questions depend on how we have defined int var. The following list may help in clarifying the above points 1Our favoured display mode for Fortran statements will be capital letters for language statements and low key letters for user-defined statements. Note that Fortran does not distinguish between capital and low key letters while C C does. 9 10 CHAPTER 2. INTRODUCTION TO C C AND FORTRAN 90 95 type in C C and Fortran 90 95 bits range char CHARACTER 8 -128 to 127 unsigned char 8 0 to 255 signed char 8 -128 to 127 int INTEGER 2 16 -32768 to .

TỪ KHÓA LIÊN QUAN