Pseudocode FORTRAN (original) INPUT number

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

Computer Programming Lab(7).
Programming Dr. Abraham Most slides are from your textbook.
Java Planning our Programs Flowcharts Arithmetic Operators.
1 Module 12 Computation and Configurations –Formal Definition –Important Terms –Examples.
Unix Continuum of Tools Do something once: use the command line Do something many times: –Use an alias –Use a shell script Do something that is complex.
Random (1) Random class contains a method to generate random numbers of integer and double type Note: before using Random class, you should add following.
Module 12 Computation and Configurations Formal Definition Examples.
Unit 171 Algorithms and Problem Solving - II Algorithm Efficiency Primality Testing Improved Primality Testing Sieve of Eratosthenes Primality Testing.
Fundamental Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
COBOL for the 21 st Century Stern, Stern, Ley Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.
COMP 14: Intro. to Intro. to Programming May 23, 2000 Nick Vallidis.
Writing algorithms using the for-statement. Programming example 1: find all divisors of a number We have seen a program using a while-statement to solve.
The break and continue statements. Introduction There are 2 special statements that can affect the execution of loop statements (such as a while-statement)
The for-statement. Different loop-statements in Java Java provides 3 types of loop-statements: 1. The for-statement 2. The while-statement 3. The do-while-statement.
Shorthand operators.
First appearedFeaturesMain paradigmsPopular uses COMPUTING Basic FOR A=1 TO 100 IF A MOD 15 = 0 THEN PRINT “FizzBuzz” ELSE IF A MOD 3 = 0 THEN PRINT “Fizz”
CSC3170 Introduction to Database Systems
Structured COBOL Programming, Stern & Stern, 9th edition
Programming Examples to Accompany Structure Topic Please use speaker notes for additional information!
Programming Concept Chapter I Introduction to Java Programming.
Software for Translators Barcelona, January 2002.
ITEC 320 C++ Examples.
BUILDING JAVA PROGRAMS CHAPTER 1 ERRORS. 22 OBJECTIVES Recognize different errors that Java uses and how to fix them.
1 CSC 110AA Introduction to Computer Science for Majors - Spring 2003 Class 5 Chapter 2 Type Casting, Characters, and Arithmetic Operators.
CSci 111 – computer Science I Fall 2014 Cynthia Zickos WRITING A SIMPLE PROGRAM IN JAVA.
Mixing integer and floating point numbers in an arithmetic operation.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
PseudocodeFORTRAN (original) INPUT number INPUT divisor intermediate = divisor intermediate
The while-statement. Syntax and meaning of the while-statement The LOOP-CONTINUATION-CONDITION is a Boolean expression (exactly the same as in the condition.
1 Programming a Computer Lecture Ten. 2 Outline  A quick introduction to the programming language C  Introduction to software packages: Matlab for numerical.
Java and C++ Transitioning. A simple example public class HelloWorldApp { public static void main(String[] args) { //Display the string. System.out.println("Hello.
First appeared Features Popular uses Assembly 1949 For code that must directly interact with the hardware (drivers), embedded processors, processor specific.
Java FilesOops - Mistake Java lingoSyntax
Boolean expressions, part 1: Compare operators. Compare operators Compare operators compare 2 numerical values and return a Boolean (logical) value A.
Invent Your Own Computer Games with Python
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
CS 100Lecture 11 Introduction to Programming n What is an algorithm? n Input and output n Sequential execution n Conditional execution Reading: Chapter.
1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,
Computer Science I Lab 1 ISMAIL ABUMUHFOUZ | CS 180.
Introduction to programming in java
Introduction to programming in java
MT262A Review.
Elementary Programming
Chapter 2 Elementary Programming
Understand argc and argv
USING ECLIPSE TO CREATE HELLO WORLD
CS305J Introduction to Computing
(A crash-course overview for humanities folk) Part I
Programming in COBOL.
Iteration statement while do-while
Chapter 5: Control Structures II
Something about Java Introduction to Problem Solving and Programming 1.
Chapter 2.
OPERATORS (1) CSC 111.
While Statement.
Computing Adjusted Quiz Total Score
CSC215 Homework Homework 04 Due date: Oct 14, 2016.
class PrintOnetoTen { public static void main(String args[]) {
Introduction to Java Brief history of Java Sample Java Program
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
Date Conversion Program
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
CSC1401 Input and Output (with Files)
Developing Java Applications with NetBeans
Developing Java Applications with NetBeans
The for-statement.
F II 2. Simple Java Programs Objectives
Hossain Shahriar CISC 101: Fall 2011 Hossain Shahriar
Chapter 11 Introduction to Programming in C
Presentation transcript:

Pseudocode FORTRAN (original) INPUT number INPUT divisor intermediate <-- number WHILE intermediate >= divisor     intermediate <-- intermediate – divisor END WHILE remainder <-- intermediate OUTPUT remainder 10 FORMAT(I4) 20 READ 10, INUM 30 READ 10, IDIVSR 40 IMED = INUM 50 IF (INUM – IDIVSR) 80, 60, 60 60     IMED = IMED – IDIVSR 70 GOTO 5 80 IREMR = IMED 90 PUNCH 1, IREMR

Pseudocode COBOL (probably buggy, modified from “Hello World” program found on the Internet) INPUT number INPUT divisor intermediate <-- number WHILE intermediate >= divisor     intermediate <-- intermediate – divisor END WHILE remainder <-- intermediate OUTPUT remainder 000100 IDENTIFICATION DIVISION. 000200 PROGRAM-ID. MODULO. 000300 000500 ENVIRONMENT DIVISION. 000600 CONFIGURATION SECTION. 000900 001000 DATA DIVISION. 001100 FILE SECTION. 001200 100000 PROCEDURE DIVISION. 100200 MAIN-LOGIC SECTION. 100300 BEGIN. 100310 ACCEPT NUMBER. 100320 ACCEPT DIVISOR. 100330 MOVE NUMBER TO INTERMEDIATE. 100340 PERFORM UNTIL INTERMEDIATE < DIVISOR 100350 SUBTRACT DIVISOR FROM INTERMEDIATE 100360 END-PERFORM. 100400 MOVE INTERMEDIATE TO REMAINDER 100500 DISPLAY REMAINDER. 100600 STOP RUN. 100700 MAIN-LOGIC-EXIT. 100800 EXIT.

BASIC (interactive, from the original 1964 Dartmouth manual) Pseudocode BASIC (interactive, from the original 1964 Dartmouth manual) INPUT number INPUT divisor intermediate <-- number WHILE intermediate >= divisor     intermediate <-- intermediate – divisor END WHILE remainder <-- intermediate OUTPUT remainder 10 DATA user_types_value_of_N 15 READ N 20 DATA user_types_value_of_D 25 READ D 30 LET I = N 40 IF I >= D GO TO 70 50    LET I = I – D 60 GO TO 40 70 LET R = I 80 PRINT R

Pseudocode C INPUT number INPUT divisor intermediate <-- number WHILE intermediate >= divisor     intermediate <-- intermediate – divisor END WHILE remainder <-- intermediate OUTPUT remainder #include <stdio.h> void main(int argc, char* argv) { int number, divisor, intermediate; scanf(“%d”, number); scanf(“%d”, divisor); intermediate = number; while (intermediate >= divisor) intermediate = intermediate – divisor; } remainder = intermediate; printf(“%d”, remainder);

Pseudocode FORTRAN 77 INPUT number INPUT divisor intermediate <-- number WHILE intermediate >= divisor     intermediate <-- intermediate – divisor END WHILE remainder <-- intermediate OUTPUT remainder PROGRAM MODULO INTEGER NUMBER, DIVISOR INTEGER INTERMEDIATE READ *, NUMBER READ *, DIVISOR INTERMEDIATE = NUMBER DO WHILE (INTERMEDIATE .GE. DIVISOR) INTERMEDIATE = INTERMEDIATE - DIVISOR END DO REMAINDER = INTERMEDIATE PRINT *, REMAINDER

BASIC (structured, as used in early Personal Computers) Pseudocode BASIC (structured, as used in early Personal Computers) INPUT number INPUT divisor intermediate <-- number WHILE intermediate >= divisor     intermediate <-- intermediate – divisor END WHILE remainder <-- intermediate OUTPUT remainder INPUT number INPUT divisor intermediate = number WHILE intermediate >= divisor intermediate = intermediate - divisor WEND remainder = intermediate PRINT remainder

Java (not object oriented, console input and output) Pseudocode Java (not object oriented, console input and output) INPUT number INPUT divisor intermediate <-- number WHILE intermediate >= divisor     intermediate <-- intermediate – divisor END WHILE remainder <-- intermediate OUTPUT remainder import java.io.*; public class Modulo { public static void main(String[] args) int number, divisor, intermediate, remainder; number = Integer.valueOf(System.console().readLine()); divisor = Integer.valueOf(System.console().readLine()); intermediate = number; while (intermediate >= divisor) intermediate = intermediate – divisor; } remainder = intermediate; System.out.println(remainder);

Visual Basic (not object oriented, console input and output) Pseudocode Visual Basic (not object oriented, console input and output) INPUT number INPUT divisor intermediate <-- number WHILE intermediate >= divisor     intermediate <-- intermediate – divisor END WHILE remainder <-- intermediate OUTPUT remainder Module Modulo Sub Main() Dim number, divisor, intermediate, remainder As Int32 Int32.TryParse(System.Console.In.ReadLine(), number) Int32.TryParse(System.Console.In.ReadLine(), divisor) intermediate = number While (intermediate >= divisor) intermediate = intermediate – divisor End While remainder = intermediate System.Console.Out.WriteLine(remainder) End Sub End Module

C# (not object oriented, Pseudocode C# (not object oriented, console input and output) INPUT number INPUT divisor intermediate <-- number WHILE intermediate >= divisor     intermediate <-- intermediate – divisor END WHILE remainder <-- intermediate OUTPUT remainder using System; class Program { static void main(string[] args) int number, divisor, intermediate, remainder; Int32.TryParse(System.Console.In.ReadLine(), out number); Int32.TryParse(System.Console.In.ReadLine(), out divisor); intermediate = number; while (intermediate >= divisor) intermediate = intermediate – divisor; } remainder = intermediate; System.Console.Out.WriteLine(remainder);