Overview of Programming: CSE115: Computing Concepts
Overview of Programming: CSE115: Computing Concepts
Overview of Programming: CSE115: Computing Concepts
Overview of Programming
CSE115: Computing
Concepts
Computer Hardware
Components
Components of a PC
Output Devices
Main Memory
Control Unit
Fetch instructions from main memory and put
them in the instruction register
ALU (Arithmetic Logic Unit)
Executes arithmetic operations
Registers
Temporarily store instructions or data fetched
from memory
Storage Devices
A magnetic device used to store a large
amount of information.
Store the software components or data
needed for the computer to execute its
tasks.
Can be read only or writable.
Example: Hard drive, CD ROM, floppy
disks
What is a program?
A program is a list of instructions for the
computer to perform a specific action or a
specific task such as:
'Calculate the sum of the numbers from 1 to 10
'Print I like programming
'Output the current time'
What is Programming?
Programming is instructing a computer to do
something for you
But computer can only understand 0 and 1!
l
It doesn't understand our language
l
How can we tell computer what to do and
how?
We can do this with the help of a
programming language
Programming Language
Can be classified into:
Machine Languages
Assembly Languages
High-Level Languages
Machine Language
The only language that the processor actually
'understands
Consists of binary codes: 0 and 1
Example: 00010101 (add 010 and 101)
11010001 (subtract 001 from 010)
01001100 (multiply 001 with 100)
Assembly Language
Enables machine code to be represented in words
and numbers.
Example of a program in assembler language:
MOV A, 010
ADD A, 101
High-Level Language
Use more English words. They try to resemble English
sentences. Therefore, it is easier to program in these
languages.
The programming structure is problem oriented - does not
need to know how the computer actually executes the
instructions.
Processor independent - the same code can be run on
different processors.
Examples: Basic, Fortran, Pascal, Cobol, C, C++, Java
A high level language needs to be translated (or, compiled)
into machine code so that it can be executed by the
processor.
l compiler is a software that can do this translation
C Programming Language
Why 'C' ?
Because based on 'B'; developed at Bell
Laboratories
Developed by Dennis Ritchie at Bell
Laboratories in the 1960s
In cooperation with Ken Thomson it was used
for Unix systems
A Simple Program in C
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Hello world!\n");
return 0;
}
A Simple Program in C
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Hello world!\n");
return 0;
}
A Simple Program in C
#include <stdio.h>
#include <stdlib.h>
Beginning of program
int main()
{
printf("Hello world!\n");
return 0;
}
A Simple Program in C
#include <stdio.h>
#include <stdlib.h>
int main()
{ Start of Segment
printf("Hello world!\n");
return 0;
} End of Segment
A Simple Program in C
#include <stdio.h>
#include <stdlib.h>
int main()
{
Function for printing text
printf("Hello world!\n");
return 0;
}
End of statement
Output
Hello world!