Dictionary of Computing - 5th Edition
.pdfLogic Function Tables
Logic Function Tables
Programming Languages
Programming Languages
The following samples demonstrate the differences in programming languages for a similar function: an input, n, is requested from the user (defining the number of entries in a list); the program loop repeats itself n times, asking for an entry and comparing it with the current biggest number entered. The biggest entry entered is then displayed on screen.
BASIC |
FORTRAN |
||
|
|
|
INTEGER BIG |
5 |
BIG=0 |
|
BIG=0 |
10 |
INPUT "How many numbers ";N |
|
READ, N |
20 |
FOR I=1 TO N |
|
DO 2 I=1, N |
30 |
INPUT X |
|
READ, C |
40 |
IF X>BIG THEN BIG=X |
2 |
IF (X.GT.BIG)BIG=X |
50 |
NEXT I |
|
PRINT, BIG |
60 |
PRINT BIG |
|
STOP |
70 |
END |
|
END |
C |
C++ |
#include <stdio.h> |
#include <iostream> |
main() |
using namespace std; |
{ |
main() |
int n, i, x, big; |
{ |
big=0; |
int n, x; |
scanf("%d", &n); |
int big = 0; |
for (i=0; i<n; i++) |
cin >> n; |
{ |
for (int i = 0; i < n; i++) |
scanf("%d", &x); |
{ |
if (x>big) |
cin >> x; |
big=x; |
if (x > big) |
} |
big = x; |
printf("%d", big); |
} |
} |
cout << big; |
|
} |