Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Computer Programming

Similar presentations


Presentation on theme: "Introduction to Computer Programming"— Presentation transcript:

1 Introduction to Computer Programming
KIC 4/7/2019 Department of Information Technology. Introduction to Computer Programming Lec 1 Introduction to Programming 4/7/2019 Introduction to Computer Programming Introduction to Computer Programming

2 Outlines What is a Computer? Structure of a Computer
Machine Languages, Assembly Languages, and High-level Languages History of C Structured Programming Basics of a Typical C Program Development Environment Sample Program Explanation

3 What is a Computer? Device capable of performing computations and making logical decisions Computers process data under the control of sets of instructions called computer programs Introduction to Computer Programming 4/7/2019

4 Hardware: Various devices comprising a computer
KIC Hardware: Various devices comprising a computer Keyboard, screen, mouse, disks, memory, CD-ROM, and processing units 4/7/2019 Introduction to Computer Programming 4/7/2019 Software : Programs that run on a computer Introduction to Computer Programming

5 Structure of a Computer
4/7/2019 Structure of a Computer Introduction to Computer Programming

6 Computer Organization
KIC Computer Organization 4/7/2019 Storage Unit Input Units Output Units Memory Unit CPU Arithmetic and Logic Unit (ALU) Control Unit Introduction to Computer Programming 4/7/2019 Introduction to Computer Programming

7 Computer Organization
Six logical units in every computer: Input unit Obtains information from input devices (keyboard, mouse) Output unit Outputs information (to screen, to printer, to control other devices) Memory unit Rapid access, low capacity, stores input information Arithmetic and logic unit (ALU) Performs arithmetic calculations and logic decisions Central processing unit (CPU) Supervises and coordinates the other sections of the computer Secondary storage unit Cheap, long-term, high-capacity storage, Stores inactive programs

8 Introduction to Computer Programming
4/7/2019

9 What are the Generations of Languages?
4/7/2019 What are the Generations of Languages? Introduction to Computer Programming

10 Fourth Generation Languages
Fourth Generation Languages ……Add C Database High-Level Languages Machine Language Assembly Language Natural Languages Introduction to Computer Programming 4/7/2019

11 Machine Languages, Assembly Languages, and High-level Languages
Strings of numbers giving machine specific instructions Example: Assembly languages English-like abbreviations representing elementary computer operations (translated via assemblers) LOAD BASEPAY ADD OVERPAY STORE GROSSPAY

12 Machine Languages, Assembly Languages, and High-level Languages
Codes similar to everyday English Use mathematical notations (translated via compilers) Example: grossPay = basePay + overTimePay

13 History of C Evolved by Ritchie from two previous programming languages, BCPL and B Used to develop UNIX Used to write modern operating systems Hardware independent (portable) By late 1970's C had evolved to "Traditional C" Standardization Many slight variations of C existed, and were incompatible Committee formed to create a "unambiguous, machine-independent" definition Standard created in 1989, updated in 1999

14 The C Standard Library C programs consist of pieces/modules called functions A programmer can create his own functions Advantage: the programmer knows exactly how it works Disadvantage: time consuming Programmers will often use the C library functions Use these as building blocks Avoid re-inventing the wheel If a premade function exists, generally best to use it rather than write your own Library functions carefully written, efficient, and portable

15 Structured Programming
Disciplined approach to writing programs Clear, easy to test and debug and easy to modify Multitasking Specifying that many activities run in parallel

16 Basics of a Typical C Program Development Environment
Basics of a Typical C Program Development Environment Program is created in the editor and stored on disk. Phases of C++ Programs: Edit Preprocess Compile Link Load Execute Preprocessor program processes the code. Loader puts program in memory. CPU takes each instruction and executes it, possibly storing new data values as the program executes. Compiler creates object code and stores it on disk. Linker links the object code with the libraries Loader Primary Memory Compiler Editor Preprocessor Linker . Disk CPU

17 Compilers (Real-World)
Real life translation Same to you buddy! Merry Christmas and Happy New Year! Huh?

18 Compilers (Computers)
Anybody who has this executable on their computer can then run (use) it. 1) A programmer writes a computer program 3) An executable program is created 2) The compiler translates the program into a form that the computer can understand

19 Introduction to C #include<stdio.h> int main() {
printf(“Hello to C programming”); }

20 Sample Program Explanation
#include<stdio.h> int main() { printf(“Hello to C programming”); } Header File Main Function Start Output Statement End

21 Preprocessor Directives
In C programming whenever you see lines that begin with a in column 1 are called preprocessor directives (commands) The #include<stdio.h> directive allows the processor to include basic Input / Output in the program at this point. #

22 stdio.h This header file is included in all programs where we need to use basic I/O commands e.g. printf(“”); Some functions are very difficult and very long to write, these header files contains built in functions to provide us help in writing the programs.

23 Each C program can contain only one main function e.g. int main()
Every C program has a main function, this is where the program starts it’s execution, as this is the first function to execute in the whole c program. Each C program can contain only one main function e.g. int main()

24 Function Body A left brace (curly bracket) -- { -- begins the body of every function. A corresponding right brace -- } -- ends the function body. int main() { …… } Main Function BODY

25 printf(“”); This line is called a C statement
printf(“”); is a function which is used to instruct computer to display something on computer screen All text, special symbols you will type inside printf(“”); between the double quotations i.e. “……..” will be displayed as it is on your computer screens except few commands like /t, /n, %i etc. e.g. printf(“Welcome at KIC”); Notice that the above line ends with a Semicolon ; (every C statement ends with a semicolon i.e. ;)

26 Introduction to Computer Programming
4/7/2019


Download ppt "Introduction to Computer Programming"

Similar presentations


Ads by Google