Download presentation
Presentation is loading. Please wait.
Published byFrederick Blankenship Modified over 9 years ago
1
©Brooks/Cole, 2003 Chapter 9 Programming Languages
2
©Brooks/Cole, 2003 Have a vision of computer language evolution. Distinguish between machine, assembly, and high-level languages. Understand the process of creating and running a program. After reading this chapter, the reader should be able to: O BJECTIVES Distinguish between the different categories of languages: procedural, object-oriented, functional, declarative, and special. Become familiar with elements of the procedural language C.
3
©Brooks/Cole, 2003 EVOLUTIONEVOLUTION 9.1
4
Figure 9-1 Evolution of computer languages
5
©Brooks/Cole, 2003 00000000000001000000000000000000 0101111000001100110000100000000000000010 11101111000101100000000000000101 11101111100111100000000000001011 1111100010101101 110111110000000000010010 01100010110111110000000000010101 1110111100000010111110110000000000010111 1111010010101101110111110000000000011110 0000001110100010110111110000000000100001 1110111100000010111110110000000000100100 011111101111010010101101 1111100010101110110001010000000000101011 0000011010100010111110110000000000110001 1110111100000010111110110000000000110100 000001000000000000111101 Program 9.1 Program in machine language 12345678910111213141516
6
©Brooks/Cole, 2003 The only language understood by a computer is machine language. Note:
7
©Brooks/Cole, 2003 Entry main,^m 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 Program 9.2 Multiplication Program in symbolic language 12345678910111213141516
8
©Brooks/Cole, 2003 /* This program reads two integer numbers from the keyboard and prints their product. */ #include int main (void) { // Local Declarations int number1; int number2; int result; // Statements cin >> number1; cin >> number2; result = number1 * number2; cout << result; return 0; }// main Program 9.3 Multiplication Program in C++ language 123456789101112131415161718
9
©Brooks/Cole, 2003 BUILDINGAPROGRAMBUILDINGAPROGRAM 9.2
10
Figure 9-2 Building a program
11
©Brooks/Cole, 2003 PROGRAMEXECUTIONPROGRAMEXECUTION 9.3
12
Figure 9-3 Program execution
13
©Brooks/Cole, 2003 CATEGORIESOFLANGUAGESCATEGORIESOFLANGUAGES 9.4
14
Figure 9-4 Categories of languages
15
©Brooks/Cole, 2003 Figure 9-5 Function in a functional language
16
©Brooks/Cole, 2003 Figure 9-6 Extracting the third element of a list
17
©Brooks/Cole, 2003 Table 9.1 Common tags Meaning Meaning ---------------------------- document document head document body document title different header levels boldface Italic underlined subscript superscript centered line break ordered list unordered list an item in the list an image an address (hyperlink) Beginning Tag ---------------- Ending Tag ----------------
18
©Brooks/Cole, 2003 Sample Document This is the picture of a book: Program 9.4 HTML Program
19
©Brooks/Cole, 2003 A PROCEDURAL LANGUAGE:C LANGUAGE:C 9.5
20
©Brooks/Cole, 2003 Figure 9-7 Variables
21
©Brooks/Cole, 2003 Table 9.2 Arithmetic operators Example Example ---------------------- 3 + 5 4 Num * 5 Sum / Count Count % 4 ----------------------- Count ++ Count Operator ---------------- Definition ---------------- Addition Subtraction Multiplication Division (quotient) Division (remainder) ----------------------- Increment Decrement
22
©Brooks/Cole, 2003 Table 9.3 Relational operators Example Example ---------------------- Num1 < 5 Num1 <= 5 Num2 > 3 Num2 >= 3 Num1 == Num2 Num1 != Num2 Operator ---------------- < Definition ---------------- Less than Less than or equal to Greater than Greater than or equal to Equal to Not equal to
23
©Brooks/Cole, 2003 Table 9.4 Logical operators Example Example ---------------------- ! ( Num1 < Num2 ) (Num1 10 ) Operator ---------------- ! && Definition ---------------- NOT AND OR
24
©Brooks/Cole, 2003 Table 9.5 Assignment operators Meaning ---------------------- Store 5 in Num Num = Num + 5 Num = Num 5 Num = Num * 5 Num = Num / 5 Num = Num % 5 Operator ---------------- == += = *= /= %= Example Example ---------------- Num = 5 Num += 5 Num = 5 Num *= 5 Num /= 5 Num %= 5
25
©Brooks/Cole, 2003 Figure 9-8 Statements
26
©Brooks/Cole, 2003 Figure 9-9 Side effect of a function
27
©Brooks/Cole, 2003 Figure 9-10 Function declaration
28
©Brooks/Cole, 2003 Figure 9-11 if-else statement
29
©Brooks/Cole, 2003 Figure 9-12 switch statement
30
©Brooks/Cole, 2003 Figure 9-13 while loop
31
©Brooks/Cole, 2003 Figure 9-14 for loop
32
©Brooks/Cole, 2003 Figure 9-15 do-while loop
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.