Chapter 9
This presentation is the property of its rightful owner.
Sponsored Links
1 / 32

Chapter 9 PowerPoint PPT Presentation


  • 52 Views
  • Uploaded on
  • Presentation posted in: General

Chapter 9. Programming Languages. O BJECTIVES. Distinguish between machine, assembly, and high-level languages. Understand the process of creating and running a program.

Download Presentation

Chapter 9

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

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.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 - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Chapter 9

Chapter 9

ProgrammingLanguages


Chapter 9

OBJECTIVES

Distinguish between machine, assembly, and high-level

languages.

Understand the process of creating and running a program.

Distinguish between the different categories of languages:procedural, object-oriented, functional, declarative, and special.

Become familiar with elements of the procedural language C.

Have a vision of computer language evolution.

After reading this chapter, the reader should be able to:


Chapter 9

9.1

EVOLUTION


Chapter 9

Figure 9-1

Evolution of computer languages


Chapter 9

Program 9.1

Program in machine language

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

00000000000001000000000000000000

0101111000001100110000100000000000000010

11101111000101100000000000000101

11101111100111100000000000001011

1111100010101101 110111110000000000010010

01100010110111110000000000010101

1110111100000010111110110000000000010111

1111010010101101110111110000000000011110

0000001110100010110111110000000000100001

1110111100000010111110110000000000100100

011111101111010010101101

1111100010101110110001010000000000101011

0000011010100010111110110000000000110001

1110111100000010111110110000000000110100

000001000000000000111101

000001000000000000111101


Chapter 9

Note:

The only language understood bya computer is machine language.


Chapter 9

Program 9.2

Program in symbolic language

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

Entry main,^m<r2>

subl2 #12,sp

jsb C$MAIN_ARGS

movab $CHAR_STRING_CON

pushal -8(fp)

pushal (r2)

calls #2,read

pushal -12(fp)

pushal 3(r2)

calls #2,read

mull3 -8(fp),-12(fp),-

pushal 6(r2)

calls #2,print

clrl r0

ret


Chapter 9

Program 9.3

Program in C++ language

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

/* This program reads two integer numbers from the

keyboard and prints their product.

*/

#include <iostream.h>

int main (void)

{

// Local Declarations

int number1;

int number2;

int result;

// Statements

cin >> number1;

cin >> number2;

result = number1 * number2;

cout << result;

return 0;

}// main


Chapter 9

9.2

BUILDING

A

PROGRAM


Chapter 9

Figure 9-2

Building a program


Chapter 9

9.3

PROGRAM

EXECUTION


Chapter 9

Figure 9-3

Program execution


Chapter 9

9.4

CATEGORIES

OF

LANGUAGES


Chapter 9

Figure 9-4

Categories of languages


Chapter 9

Figure 9-5

Function in a functional language


Chapter 9

Figure 9-6

Extracting the third element of a list


Chapter 9

Table 9.1 Common tags

Beginning Tag

----------------

<HTML>

<HEAD>

<BODY>

<TITLE>

<Hi>

<B>

<I>

<U>

<SUB>

<SUP>

<CENTER>

<BR>

<OL>

<UL>

<LI>

<IMG>

<A>

Ending Tag

----------------

</HTML>

</HEAD>

</BODY>

</TITLE>

</Hi>

</B>

</I>

</U>

</SUB>

</SUP>

</CENTER>

</OL>

</UL>

</LI>

</A>

Meaning----------------------------

document

document head

document body

document title

different header levelsboldface

Italic

underlined

subscript

superscript

centered

line break

ordered list

unordered list

an item in the list

an image

an address (hyperlink)


Chapter 9

Program 9.4

HTML Program

<HTML>

<HEAD>

<TITLE> Sample Document </TITLE>

</HEAD>

<BODY>

This is the picture of a book:

<IMG SRC="Pictures/book1.gif" ALIGN=MIDDLE>

</BODY>

</HTML>


Chapter 9

9.5

A PROCEDURAL

LANGUAGE:

C


Chapter 9

Figure 9-7

Variables


Chapter 9

Table 9.2 Arithmetic operators

Operator

----------------

+

-

*

/

%

----------

++--

Definition

----------------

Addition

Subtraction

Multiplication

Division (quotient)

Division (remainder)

-----------------------

Increment

Decrement

Example----------------------

3 + 5

2 - 4

Num * 5

Sum / Count

Count % 4

-----------------------

Count ++

Count --


Chapter 9

Table 9.3 Relational operators

Operator

----------------

<

<=

>

>=

==

!=

Definition

----------------

Less than

Less than or equal to

Greater than

Greater than or equal to

Equal to

Not equal to

Example----------------------

Num1 < 5

Num1 <= 5

Num2 > 3

Num2 >= 3

Num1 == Num2

Num1 != Num2


Chapter 9

Table 9.4 Logical operators

Operator

----------------

!

&&

||

Definition

----------------

NOT

AND

OR

Example----------------------

! ( Num1 < Num2 )

(Num1 < 5 ) && (Num2 > 10 )

(Num1 < 5 ) || (Num2 > 10 )


Chapter 9

Table 9.5 Assignment operators

Operator

----------------

==

+=

-=

*=

/=

%=

Example

----------------

Num = 5

Num += 5

Num -= 5

Num *= 5

Num /= 5

Num %= 5

Meaning----------------------

Store 5 in Num

Num = Num + 5

Num = Num - 5

Num = Num * 5

Num = Num / 5

Num = Num % 5


Chapter 9

Figure 9-8

Statements


Chapter 9

Figure 9-9

Side effect of a function


Chapter 9

Figure 9-10

Function declaration


Chapter 9

Figure 9-11

if-else statement


Chapter 9

switch statement

Figure 9-12


Chapter 9

Figure 9-13

while loop


Chapter 9

for loop

Figure 9-14


Chapter 9

do-while loop

Figure 9-15


  • Login