CSCE 206 1 Syntax Details Fortran is not case sensitive; any use of capitals is for the programmer’s convenience. All programs are “wrapped” with PROGRAM.

Slides:



Advertisements
Similar presentations
1 Chapter 2 Basic Elements of Fortran Programming.
Advertisements

Pascal Programming Today Chapter 4 1 »Conditional statements allow the execution of one of a number of possible operations. »Conditional statements include:
 2005 Pearson Education, Inc. All rights reserved Introduction.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Class 7.
Expressions ► An expression can be a single variable, or can include a series of variables. If an expression includes multiple variables they are combined.
Javascript Essentials How do I write it??  Start Homesite  Between the start and end BODY tags type: 
True or false A variable of type char can hold the value 301. ( F )
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
1 Outline 13.1Introduction 13.2A Simple Program: Printing a Line of Text in a Web Page 13.3Another JavaScript Program: Adding Integers 13.4Memory Concepts.
Announcements Quiz 1 Next Week. int : Integer Range of Typically -32,768 to 32,767 (machine and compiler dependent) float : Real Number (i.e., integer.
Chapter 2 Basic Elements of Fortan
CS31: Introduction to Computer Science I Discussion 1A 4/2/2010 Sungwon Yang
JavaScript, Fourth Edition
CS241 PASCAL I - Control Structures1 PASCAL I - Control Structures Philip Fees CS241.
JavaScript, Third Edition
1 CIS Jan Overview Evolution of C++ Programming Style Syntax & Semantics Comments & White Space Data Types Variables & Declarations cout.
Testing a program Remove syntax and link errors: Look at compiler comments where errors occurred and check program around these lines Run time errors:
Introduction To C++ Programming 1.0 Basic C++ Program Structure 2.0 Program Control 3.0 Array And Structures 4.0 Function 5.0 Pointer 6.0 Secure Programming.
1 Chapter Two Using Data. 2 Objectives Learn about variable types and how to declare variables Learn how to display variable values Learn about the integral.
Introduction to FORTRAN-90 University of Liverpool course.
Java Primitives The Smallest Building Blocks of the Language (corresponds with Chapter 2)
Variables, Assignment & Math Storing and naming data.
1 The CONST definition CONST Pi = , City = ‘New York’; Constant identifiers are used when you do not want the value of an identifier to change why.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
Chapter 3: Data Types and Operators JavaScript - Introductory.
Chapter 2 Basic Elements of Java. Chapter Objectives Become familiar with the basic components of a Java program, including methods, special symbols,
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
1 CSC103: Introduction to Computer and Programming Lecture No 6.
Input, Output, and Processing
Chapter 2: Using Data.
 JAVA Compilation and Interpretation  JAVA Platform Independence  Building First JAVA Program  Escapes Sequences  Display text with printf  Data.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 2 Basic Elements of Java.
NA2204.1jcmt CSE 1320 Intermediate Programming C Program Basics Structure of a program and a function type name (parameters) { /* declarations */ statement;
BASICS CONCEPTS OF ‘C’.  C Character Set C Character Set  Tokens in C Tokens in C  Constants Constants  Variables Variables  Global Variables Global.
Selection Relational Expressions A condition or logical expression is an expression that can only take the values true or false. A.
Lecture #6 OPERATORS AND ITS TYPES By Shahid Naseem (Lecturer)
1 Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
 2000 Deitel & Associates, Inc. All rights reserved. Outline 8.1Introduction 8.2A Simple Program: Printing a Line of Text in a Web Page 8.3Another JavaScript.
Chapter-4 Managing input and Output operation.  Reading, processing and writing of data are three essential functions of a computer program.  Most programs.
Sections © Copyright by Pearson Education, Inc. All Rights Reserved.
CS241 PASCAL I - Control Structures1 PASCAL Control Structures Modified Slides of Philip Fees.
Operators and Expressions. 2 String Concatenation  The plus operator (+) is also used for arithmetic addition  The function that the + operator performs.
Arithmetic Expressions in C++. CSCE 1062 Outline Data declaration {section 2.3} Arithmetic operators in C++ {section 2.6} Mixed data type arithmetic in.
Lecture III Start programming in Fortran Yi Lin Jan 11, 2007.
Types of C Variables:  The following are some types of C variables on the basis of constants values it has. For example: ○ An integer variable can hold.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 2A Reading, Processing and Displaying Data (Concepts)
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Fluency with Information Technology Third Edition by Lawrence Snyder Chapter.
Control statements Mostafa Abdallah
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
ITM © Port, KazmanVariables - 1 ITM 352 Data types, Variables Class #4.
1 st Semester Module2 Basic C# Concept อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
1Object-Oriented Program Development Using C++ Built-in Data Types Data type –Range of values –Set of operations on those values Literal: refers to acceptable.
ISBN Chapter 7 Expressions and Assignments Statements.
Chapter 2 – Data Types We start now to deal with details of “syntax”
ITM 352 Data types, Variables
Chapter 7: Expressions and Assignment Statements
BASIC ELEMENTS OF A COMPUTER PROGRAM
ITEC113 Algorithms and Programming Techniques
Data Types, Identifiers, and Expressions
Chapter 7: Expressions and Assignment Statements
Test Review Computer Science History
Arithmetic operations & assignment statement
Revision Lecture
Introduction to C++ Programming
Numbers.
Chapter 2: Introduction to C++.
DATA TYPES AND OPERATIONS
Presentation transcript:

CSCE Syntax Details Fortran is not case sensitive; any use of capitals is for the programmer’s convenience. All programs are “wrapped” with PROGRAM program_name END PROGRAM program_name

CSCE Syntax Details Symbols/Identifiers Must start with an alpha character Must be alphanumeric or underscore characters Must be lessequal 31 characters long

CSCE Syntax Details Declaration of variables IMPLICIT none should always be used REAL :: list of real variables INTEGER :: list of integer variables LOGICAL :: list of logical variables COMPLEX :: list of complex variables CHARACTER :: list of char variables CHARACTER(nn) :: list of char variables CHARACTER(LEN=nn) :: list of char variables

CSCE Syntax Details REAL,PARAMETER :: x = value Makes the variable a constant whose value cannot be changed from that originally assigned to it

CSCE Syntax Details—Arithmetic Expressions Exponentiations first, left to right, with multiple exponentiations done right to left Then mults and divs left to right with equal priority Then adds and subs left to right with equal priority Must include all operators between operands Cannot use multiple + or – signs in sequence DO NOT RELY ON THE RULES PARENTHESISE FOR CLARITY

CSCE Syntax Details—Arithmetic Expressions Detailed rules exist for arithmetic evaluation Ignore the rules Parenthesise as needed to ensure clarity, and use the builtin functions INT(), REAL(), etc., so that there is no question as to what you intend to be the result of your expression.

CSCE Syntax Details--Assignments Written var = expression but interpreted var  expression Continuation to line n+1 indicated with & at the end of line n Up to 132 characters per line, up to 39 continuation lines permitted for a single statement

CSCE Input and Output PRINT *, list of variables WRITE(6,*) list of variables WRITE(6,nn) list of variables nnFORMAT(format statement here) The first two are “free format” and the last pair is a specifically formatted output statement By default, “unit 5” is stdin for reading and “unit 6” is stdout for writing READ *, list of variables READ(6,*) list of variables

CSCE Input and Output from Files OPEN(UNIT=n,FILE=“filename”,STATUS=“OLD”) READ(n,*) list of variables CLOSE(n) will allow reading from an external file filename Similarly, for writing, we would use OPEN(UNIT=n,FILE=“filename”,STATUS=“NEW”) WRITE(n,*) list of variables CLOSE(n) To open/create a file filename and write to it Format statements can also be used

CSCE Logical Expressions.EQ..NE..LT..GT..LE..GE..AND..OR..NOT..TRUE..FALSE. Rules of Boolean logic apply Precedence rules apply, but can be ignored if you remember to parenthesise properly

CSCE If-Then-Else IF(logical expression) THEN sequence of statements END IF label: IF(logical expression) THEN sequence of statements END IF label The labelling can be used on all IF statement structures

CSCE If-Then-Else IF(logical expression) THEN sequence of statements ELSE sequence of statements END IF

CSCE If-Then-Else IF(logical expression) THEN sequence of statements ELSE IF (logical expression) THEN sequence of statements. ELSE sequence of statements END IF

CSCE If-Then-Else SELECT CASE (selector variable) CASE(values) sequence of statements CASE(values) sequence of statements. CASE DEFAULT sequence of statements END SELECT

CSCE The End