Introduction
By; Engr. Muhammad Athar Javed Sethi
Lecture 1
Course Information
Course Course Course Course Code: CSE-102 Name: Computer Programming Credit Hours: 4(3+1) Group Address:
http://www.groups.yahoo.com/group/uetp_crash2010_compr og
MEMORY ORGANIZATION
10001000100101
DATA
01001010101010
DATA
CPU
11100101010101
INSTRUCTION
10101000011001
PROGRAM
MEMORY
LOW AND HIGH LEVEL PROGRAMMING Lowest Level: Machine Codes Directly process able, written in Binary: 10001011 01100111 10011011 11000111 Hard to read, slow to create, fast to run.
LOW AND HIGH LEVEL PROGRAMMING Next lowest level: Assembler Mnemonics directly represent machine code, Symbolic, :
mov A,90h inc A jnz loop1
LOW AND HIGH LEVEL PROGRAMMING High level: Pascal, C, Fortran, C++/Java One statement is equivalent of many machine code operations. (How???) Human understandable, fast to write, inefficient (?) in terms of code size and run speed, portable between processors.
High-Level Language
#include <stdio.h> int main() { printf(HelloWorld); return 0; }
10100110 01110110 00100110 00000000 11111010 11111010 01001110 10100110 11100110 10010110 11001110 00101110 10100110 01001110 11111010 01100110 01001110 10000110 etc...
Source code
Executable code
Compilers and linkers translate a high level program into executable machine code.
What is C Language C is general purpose programming language, closely associated with the UNIX system (operating system), where it was developed. 1972: C language developed at Bell Labs.
Dennis Ritchie wrote C for Unix.
C is portable, not tied to any particular operating system or machine. A structured programming language.
What is C Language(CONT)
Programs written in C are efficient, as they are smaller and faster than corresponding programs written in other programming languages. Extremely powerful and wealthy library. C is flexible, used to write applications for a variety of areas.
CAD, games, commercial systems, AI (expert systems, robotics). Process Control and real time systems. System program such as operating systems, compilers, linkers etc.
There is very little error checking etc. it assumes that you know what you are doing.
Why C Language
Structured language.
Sequence, selection, repetition.
Relatively small language, described in a small space and learned quickly. Standard library exists, allowing portability. It allow us write clear, concise programs that are portable and efficient. C is the basis for many other languages (Java,Verilog,C++). Low level activities possible. It can produce clean and efficient code. Preferred language for OS (operating Systems).
C and C++
Traditionally C programs use the file extension .C and C++ programs the extension .CPP C is essentially a subset of C++, so you could use a C++ compiler to run a C program. The two languages are extremely similar. In the labs we will be using a Turbo C++ Version 3 software.