Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 101 INTRODUCTION TO PROGRAMMING

Similar presentations


Presentation on theme: "CS 101 INTRODUCTION TO PROGRAMMING"— Presentation transcript:

1 CS 101 INTRODUCTION TO PROGRAMMING
refercence: Computer Science Department Jordan University of Science and Technology refercence:

2 refercence: www.netacad.com

3 refercence: www.netacad.com
To start: refercence:

4 refercence: www.netacad.com
CS101 CS112 refercence:

5 Categories of Computers
Super Computers Mainframe computers Midsize computers personal computers Embedded computers C++ Programming: From Problem Analysis to Program Design, Third Edition

6 Elements of a Computer System
Hardware Central Processing Unit (CPU) Main Memory Secondary Storage Input/ Output Devices Software C++ Programming: From Problem Analysis to Program Design, Third Edition

7

8 Central Processing Unit (CPU)
The main components of the CPU are: Control unit (CU) Arithmetic and logic unit (ALU). Registers. C++ Programming: From Problem Analysis to Program Design, Third Edition

9 Central Processing Unit (CPU)
CU (Control Unit): Fetches and decodes instructions Controls flow of information in and out of MM Controls operation of internal CPU components ALU (arithmetic logic unit): carries out all arithmetic and logical operations C++ Programming: From Problem Analysis to Program Design, Third Edition

10 Central Processing Unit (CPU)
3. Registers. PC (program counter): points to next instruction to be executed IR (instruction register): holds instruction currently being executed C++ Programming: From Problem Analysis to Program Design, Third Edition

11 Main Memory Directly connected to the CPU
All programs must be loaded into main memory before they can be executed All data must be brought into main memory before it can be manipulated When computer power is turned off, everything in main memory is lost C++ Programming: From Problem Analysis to Program Design, Third Edition

12

13 Secondary Storage Secondary storage: Device that stores information permanently Examples of secondary storage: Hard disks Floppy disks Zip disks CD-ROMs Tapes Flash drives C++ Programming: From Problem Analysis to Program Design, Third Edition

14 Input/output Devices Input devices feed data and programs into computers. They include: Keyboard Mouse Secondary storage Output devices display results. They include: Monitor Printer C++ Programming: From Problem Analysis to Program Design, Third Edition

15 Software Software: Programs that do specific tasks
1. System programs take control of the computer, such as an operating system Operating System monitors the overall activity of the computer and provides services. 2. Application programs perform a specific task Word processors Spreadsheets Games Software are usullay witten using a programming language.

16 1.1 Natural language vs. programming language
Reference:

17 1.1 Natural language vs. programming language
What is a language? a language is a tool for expressing and recording human thoughts What is a programming language? A programming language is defined by a certain set of rigid rules, these rules determine which symbols (letters, digits, punctuation marks, and so on) could be used in the language Reference:

18 1.1 Natural language vs. programming language
Any programming language consists of: Syntax: is a set of rules determines the appropriate ways of collating the symbols Semantic: the ability to recognize the meaning of every statement expressed in the given language Any program we write must be error-free in these three ways: lexically, syntactically and semantically, otherwise, the program won’t run, or it will produce unacceptable results Reference:

19 1.1 Natural language vs. programming language
Why we need to use a programming language? The machine language is the simplest and the most primary language we can use to give commands to our computer (very difficult to understand for humans) A high-level programming language is a bridge between the people's language (natural language) and computer language (machine language) A high-level programming language is similar to a natural language: it uses symbols, words and conventions readable to humans. High-level languages include Basic, FORTRAN, COBOL, Pascal, C, C++, C#, and Java Reference:

20 The Language of a Computer
Digital signals are sequences of 0s and 1s Machine language: language of a computer Binary digit (bit): The digit 0 or 1 Binary code: A sequence of 0s and 1s Byte: A sequence of eight bits C++ Programming: From Problem Analysis to Program Design, Third Edition

21

22 Programming Language Evolution
Early computers were programmed in machine language To calculate wages = rates * hours in machine language: //Load //Multiply //Store C++ Programming: From Problem Analysis to Program Design, Third Edition

23 Assembly Language Assembly language instructions are mnemonic.
Mnemonic (easy-to-remember). Assembler: translates a program written in assembly language into machine language C++ Programming: From Problem Analysis to Program Design, Third Edition

24 High-Level Languages High-level languages include Basic, FORTRAN, COBOL, Pascal, C++, C, and Java Compiler: translates a program written in a high-level language machine language The equation wages = rate • hours can be written in C++ as: wages = rate * hours; C++ Programming: From Problem Analysis to Program Design, Third Edition

25 Processing a C++ Program
#include <iostream> using namespace std; int main() { cout << "My first C++ program." << endl; return 0; } Sample Run: My first C++ program. C++ Programming: From Problem Analysis to Program Design, Fifth Edition Reference:

26 Installing and using your programming environment
Chapter 0 Installing and using your programming environment refercence:

27 Creating your work environment:
Where to write your code? Paper and a pencil!! Its good for first draft You requires a computer equipped with some additional tools. refercence:

28 Processing a C++ Program (cont'd.)
To execute a C++ program: Use an editor to create a source program in C++ Preprocessor directives begin with # and are processed by the preprocessor. (A set of preliminary information that the compiler needs is included in header files such iostream header file) Use the compiler to: Check that the program obeys the rules Translate into machine language (object program) Linker: Combines object program with other programs provided by the SDK to create executable code Loader: Loads executable program into main memory The last step is to execute the program C++ Programming: From Problem Analysis to Program Design, Fifth Edition Reference:

29 Processing a C++ Program (cont'd.)
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Reference:

30 refercence: www.netacad.com
What is IDE? refercence:

31 refercence: www.netacad.com
What is IDE? IDE (Integrated Development Environment) is a software application that typically consists of a code editor, a compiler, a debugger, and a graphical user interface (GUI) builder. Programming with an IDE gives you a toolkit containing everything you may need. However, they may consume a lot of resources and, you probably don’t need most of the functions they can perform. refercence:

32 refercence: www.netacad.com
Using on-line tools Using on-line tools allows you to write, store and run your code without installing anything refercence:

33 refercence: www.netacad.com
Choose your IDE There are many IDEs on the market, both free and not free We wrote and tested all our examples with NetBeans. refercence:

34 refercence: www.netacad.com
Choose your IDE Microsoft © Visual Studio Express ® (Now changed to: Visual Studio Community) A single-platform development environment designed especially for building C++ programs, both under and for the MS Windows operating system. Now it has even multi-platform support: Runs on Windows and MacOS to develop applications for Android, iOS, Windows, web, and cloud. home site:  refercence:

35 refercence: www.netacad.com
Choose your IDE Eclipse Multi-platform development environment designed especially for Java. C++ programming possible without additional configuration (dedicated C++ version available for download). home site:  downloads:  license: Eclipse Public License (free and open) refercence:

36 refercence: www.netacad.com
Choose your IDE NetBeans Multi-platform development environment designed especially for Java. C++ programming possible without additional configuration (dedicated C++ version available for download). home site:  downloads:  license: Common Development and Distribution License or GNU Public License version 2 (free and open) refercence:

37 refercence: www.netacad.com
Choose your IDE Code::Blocks Multi-platform development environment designed for C/C++ programming. Default Windows installer does not include C++ compiler - use the one containing “mingw-setup” inside the file name instead. home site:  downloads:  license: GNU Public License version 3 (free and open) refercence:

38 refercence: www.netacad.com
Choose your IDE XCode Single-platform development environment designed especially for building applications for operating systems designed by Apple Inc. Programming in C++ fully available. home site:  downloads:  license: proprietary but free for Max OS X users; integrated with OS X and preinstalled. refercence:

39 refercence: www.netacad.com
 On-line tools: ideone refercence:

40 refercence: www.netacad.com
 On-line tools: ideone The first one is a tool named ideone available at  Although you don’t need to register to start your work, we suggest that you do – it’ll enable some additional, valuable features. After signing in, you’ll have to do some customizing, and two things are essential: change your default programming language to “C++” (don't forget to do that) enable syntax highlighting – it’ll make it easier to do your work.  For help: Check  more details. refercence:

41 refercence: www.netacad.com
 On-line tools: ideone To test the ideone environment, go to the “new code” tab and just copy-and-paste the following text into the source code field: #include <iostream> using namespace std; int main(void) { cout << "It's working" << endl; return 0; } refercence:

42 refercence: www.netacad.com
On-line tools: cpp.sh Another on-line tool with very similar functionality is C++ shell, available at  You don’t need to register and its principle operation is very similar to ideone, although C++ shell doesn't offer as many useful features as ideone (e.g. you can neither save nor publish your code). It also doesn't include any support (to tell you the truth, it’s so simple to use that you actually don’t need any help) Now it's time to start learning some real programming. Let us go to chapter 1 refercence:


Download ppt "CS 101 INTRODUCTION TO PROGRAMMING"

Similar presentations


Ads by Google