(C++, Go) are converted directly into machine native code by a compiler program.
In interpreted languages (Python, JavaScript), there are no build steps. Instead, interpreters operate on the source code of the program while executing it.
Java can be considered both a compiled and an interpreted language because its source code is first compiled into a binary byte-code. This byte-code runs on the Java Virtual Machine (JVM), which is usually a software-based interpreter. The use of compiled byte-code allows the interpreter (the virtual machine) to be small and efficient (and nearly as fast as the CPU running native, compiled code).
- Start
- A < -- 10
- Z < -- A > 50
- PRINT Z
- END
A high-level language (HLL) is a programming language such as C, FORTRAN, or Pascal that enables a programmer to write programs that are more or less independent of a particular type of computer. Such languages are considered high-level because they are closer to human languages and further from machine languages.
In contrast, assembly languages are considered low-level because they are very close to machine languages.
Examples of used high-level languages:
Python.
Java.
C++
C#
Visual Basic.
JavaScript.
_1983= 11110111111
2ˆ10 | 2ˆ9 | 2ˆ8 | 2ˆ8 | 2ˆ6 | 2ˆ5 | 2ˆ4 | 2ˆ3 | 2ˆ2 | 2ˆ1 | 2ˆ0 |
---|---|---|---|---|---|---|---|---|---|---|
1024 | 512 | 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1 | 1 | 1 | 1 | 0 | 1 | 1 | 1 | 1 | 1 | 1 |
Create a program to add two numbers given by the user
:
.data
n1: .asciiz "enter your first number: "
n2: .asciiz "enter your second number: "
result: .asciiz "result is "
.text
#getting first input.
la $a0, n1
li $v0, 4
syscall
li $v0, 5
syscall
move $t0, $v0
#getting second input.
la $a0, n2
li $v0, 4
syscall
li $v0, 5
syscall
move $t1, $v0
#calculate and print out the result.
la $a0, result
li $v0, 4
syscall
add $t3, $t0, $t1
move $a0, $t3
li $v0, 1
syscall
#end program.
li $v0, 10
syscall
Using For:
for (let i = 0; i < 9; i++) {
console.log(i);
// more statements
}
var cond = false;
if (cond == true)
{ console.log('The cond variable is true'); }
else { console.log('The cond variable is false'); }
The code was using an assignment instead of a comparision expression.
var n = 100;
if (n == 100) {
console.log('This is a special number!');
} else if (n < 1000 && n % 10 == 0) {
console.log('This number is almost special');
} else {
console.log('Just a regular number');
}