Download Computer Programming Languages - Computer Fundamentals - Lecture Slides and more Slides Computer Science in PDF only on Docsity!
Contents
- Today's Topic: Computer Programming Languages
- We will learn
- Computer Programming Languages.
- Non-computational languages
- Machine language » Example
- Assembly language » Example
- High level language » Examples.
Computer Programming
Languages
Computer Programming Languages
(Contd…):
- Programming languages are used to facilitate communication about the task of organizing and manipulating information, and to express algorithms precisely.
- For 50 years, computer programmers have been writing code. New technologies continue to emerge, develop, and mature at a rapid pace. Now there are more than 2,500 documented programming languages!
Non-computational
languages:
- Non-computational languages , such as markup languages like HTML or formal grammars like BNF, are usually not considered programming languages.
- Often a programming language is embedded in the non- computational language.
Machine language:
- While easily understood by computers, machine languages are almost impossible for humans to use because they consist entirely of numbers.
For example , an x86/IA-32 processor can execute the following binary instruction as expressed in machine language:
Binary: 10110000 01100001 (Hexadecimal: 0xb061)
Assembly Level Language:
- An assembly language is a low-level language for programming computers.
- The word " low " does not imply that the language is inferior to high-level programming languages but rather refers to the small or nonexistent amount of abstraction between the language and machine language, because of this, low-level languages are sometimes described as being " close to the hardware ."
- It implements a symbolic representation of the numeric machine codes and other constants needed to program a particular CPU architecture.
Example (Adds 2 numbers):
name "add"
mov al, 5 ; bin=00000101b
mov bl, 10 ; hex=0ah or bin=00001010b
add bl, al ; 5 + 10 = 15 (decimal) or hex=0fh or
bin=00001111b
High-level language:
- High-level languages are relatively easy to learn because the instructions bear a close resemblance to everyday language, and because the programmer does not require a detailed knowledge of the internal workings of the computer.
- Each instruction in a high-level language is equivalent to several machine-code instructions, therefore it is more compact than equivalent low-level programs.
- High-level languages are used to solve problems and are often described as problem-oriented languages
Example (C program to add 2
numbers):
#include<stdio.h> //header files Void main() { int a, b, c; // declaration of 3 variables printf(“Enter two numbers:\n”); Scanf(“%d”, &a); // read 1 st^ number Scanf(“%d”, &b); // read 2 nd^ number c=a+b; // compute the sum printf(“Sum of 2 numbers is %d”, c); //print sum }