Programming HSPM J713 Programming languages and systems
Download

Programming HSPM J713 Programming languages and systems







Advertisement
/ 15 []
Download Presentation
Comments
Kelvin_Ajay
From:
|  
(941) |   (0) |   (0)
Views: 168 | Added: 14-12-2010
Rate Presentation: 0 0
Description:
Programming languages generally come with programming system. The language part of a programming language is the key words, symbols, and syntax used to write code. ...
Programming HSPM J713 Programming languages and systems

An Image/Link below is provided (as is) to

Download Policy: Content on the Website is provided to you AS IS for your information and personal use only and may not be sold or licensed nor shared on other sites. SlideServe reserves the right to change this policy at anytime. While downloading, If for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.











- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -




Slide 1

Programming

HSPM J713

Slide 2

Programming languages and systems

  • Programming languages generally come with programming system

  • The language part of a programming language is the key words, symbols, and syntax used to write code.

  • The system part translates the written code into machine instructions that computer executes. Can be a compiler or an interpreter.

Slide 3

Platform-specific

  • Language system works with specific hardware

  • The “IBM-compatible” PC or the Windows PC

  • All use the same:

    • Machine instructions (which depends on chip architecture)

    • Memory, screen

Slide 4

Assembly language

mov ax, 1234h

mov bx, ax

Directly translates into machine code (binary numbers)

Compiler translates all instructions in program into machine code

Low level – explicitly manipulates registers (places to hold data) on the CPU chip.

Each chip has its own assembly language

Slide 5

FORTRAN

Do 10 j = 2 , 1000

B(j) = A(j-1)

A(j-1)=j

10 continue

Compiled into machine language and then run

Used on mainframes since 1950’s.

Designed for math

Slide 6

BASIC

Beginner's All-purpose Symbolic Instruction Code

For students and general users

Interpreted – One line at a time is translated into machine code and executed

Slide 7

BASIC – unstructured, interpreted

10 INPUT "What is your name: ", U$

20 PRINT "Hello "; U$

30 INPUT "How many stars do you want: ", N

40 S$ = ""

50 FOR I = 1 TO N

60 S$ = S$ + "*"

70 NEXT I

80 PRINT S$

90 INPUT "Do you want more stars? ", A$

100 IF LEN(A$) = 0 THEN 90

110 A$ = LEFT$(A$, 1)

120 IF A$ = "Y" OR A$ = "y" THEN 30

130 PRINT "Goodbye ";U$

140 END

Slide 8

BASIC structured, compiled

INPUT "What is your name: ", UserName$

PRINT "Hello "; UserName$

DO

INPUT "How many stars do you want: ", NumStars

Stars$ = STRING$(NumStars, "*")

PRINT Stars$

DO

INPUT "Do you want more stars? ", Answer$

LOOP UNTIL Answer$ <> ""

Answer$ = LEFT$(Answer$, 1)

LOOP WHILE UCASE$(Answer$) = "Y"

PRINT "Goodbye "; UserName$

Slide 9

C, C++

  • This Hello world program uses the C++ standard library stream facility to write a message to standard output:

    #include <iostream> // provides std::cout

    int main() {

    std::cout << "Hello, world!\n";

    }

    Uses “library” of code, callable with key words, to execute complex tasks

    Compiler for specific platform translates that into machine code.

Slide 10

Java

  • Compiled code runs on Virtual Machine

  • A virtual machine is written for each platform.

    • The virtual machine for a platform translates virtual machine instructions into machine instructions for that platform

    • Java runs on PC virtual machine on PC’s, Macintosh virtual machine on Macs, for example.

  • So compiled Java code can run on many platforms. Good for web applications.

Slide 11

Java resembles C in syntax

Class HelloWorld {

public static void main (String[] arguments) {

System.out.println(“Hello World!”);

}

}

Compiled using Java Development Kit

Slide 12

Java uses objects

import java.applet.*;

import java.awt.*;

public class TextEntry extends Applet {

TextField Reply;

TextField Entry;

public void init() {

setBackground(Color.white);

add("EntryLabel", new Label("Type your number in the small box and press Enter:"));

add("Entry", Entry = new TextField("", 5));

add("Reply", Reply = new TextField("My reply will appear here.", 60));

Reply.setEditable(false);

}

public void compute() {

int value;

try {

value = Integer.valueOf(Entry.getText().trim()).intValue();

if (value == 15) {

Reply.setText("Correct! 15 is right!");

}

else {

if (value > 15) Reply.setText(Entry.getText()+" is too high.");

if (value < 15) Reply.setText(Entry.getText()+" is too low.");

}

} catch(NumberFormatException e) {

Reply.setText(Entry.getText() + " is not a number.");

}

}

public boolean action(Event e, Object dummy) {

compute();

return(true);

}

}

Textentry example

Slide 13

Java uses objects

import java.applet.*;

import java.awt.*;

public class TextEntry extends Applet {

TextField Reply;

TextField Entry;

}

Slide 14

Java uses objects

public class TextEntry extends Applet {

TextField Reply;

TextField Entry;

public void init() {

setBackground(Color.white);

add("EntryLabel", new Label("Type your number in the small box and press Enter:"));

add("Entry", Entry = new TextField("", 5));

add("Reply", Reply = new TextField("My reply will appear here.", 60));

Reply.setEditable(false);

}

}

Slide 15

Java uses objects

public void compute() {

int value;

try {

value = Integer.valueOf(Entry.getText().trim()).intValue();

if (value == 15) { Reply.setText("Correct! 15 is right!"); }

else {

if (value > 15) Reply.setText(Entry.getText()+" is too high.");

if (value < 15) Reply.setText(Entry.getText()+" is too low.");

}

}

catch(NumberFormatException e) { Reply.setText(Entry.getText() + " is not a number.");}

}

public boolean action(Event e, Object dummy) {

compute();

return(true);

}

}


Copyright © 2014 SlideServe. All rights reserved | Powered By DigitalOfficePro