1 / 54

C++ Programming: Lecture One

This lecture covers the basics of structured programming using the C++ language, including program structure, variables, operators, selections, and repetitions. Taught by Dr. Yahya AL-Mayali.

irenea
Download Presentation

C++ Programming: Lecture One

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Structure Programming Languages Using C++C++-Lecture OneInstructor: Dr. Yahya AL Mayali Humanities' Studies University College Department of Computer Technologies Engineering د.يحيى الميالي

  2. بسم الله الرحمن الرحيم يرحب قسم هندسة تقنيات الحاسوب بطلبة المرحلة الأولى للسنة الدراسية 20132014- نتمنى لطلبتنا الأعزاء سنة دراسية مكللة بالنجاح الباهر... د. يحيى الميالي د.يحيى الميالي

  3. Structured Programming using C++ Programming Course Syllabus for Computer Science مفردات مادة البرمجة المهيكلة-1 بأستخدام لغة C++ Computer and Programming Languages Concepts Top-Down Process and Structured Programming and Limitations Problem, Data, algorithms and problem Solving Methodology A C++ Definition ,History C++ & Program Structure Cout, cin commands and comments for clarity and understanding, Preprocessors Directives, Identifiers, Variables, Constant Names, Types and declaration Assign Statements, Arithmetic's Operators (unary, Binary, and Compounds operators), increments, decrements, and Library Mathematic Functions and Manipulators Selections and Repetitions, Structure Programming, Scope of variables and Relational Operators د.يحيى الميالي

  4. C++ Syllabus Continue • Functions to Aid Program modularity, Passing Arguments and returning values • Array for grouping data of same types( one, two dimensions) Manipulating, • Vectors, and matrices • Reading data from a file and writing data to a file • Define a structures to group data, nested structures, Encapsulation of data and functions in classes, Define objects used as function arguments and return values • Define, and manipulating strings Define, and Manipulating Pointers • Subjects review • References: • "Programming and Problem Solving with C++", by Nell Dale, • "A C++ Primer for Engineers, an object-oriented Approach", • by K. Ponnambalam and Tiuley Alguindigue. • "Introduction to programming with C++", by Peter Muller. • "C++ البرمجة باستخدام " للمؤلف هيوبارد • “C/C++ تعلم بدون تعقيد وتطبيقاتها العملية”للمؤلف المهندس مصطفى ماجد د.يحيى الميالي

  5. What is a computer? • A computer is a device capable of performing computations and making logical decisions at speeds billions of times faster than human being can. • Computers process data under the control of sets of instructions called computer programs. • These computer programs guide the computer through orderly sets of actions specified by people called programmers. • A computer is compromised of various devices: ( such as keyboard, screen, mouse, disk, memory, and processing unit which is the CPU) these devices referred to as hardware د.يحيى الميالي

  6. Computer Consists of: Hardware كيانات مادية Software برمجيات د.يحيى الميالي

  7. Hardware (Computer System) • PC ( Personnel Computer • PC ( Personnel Computer • Workstation • Workstation • Mainframe • Mainframe د.يحيى الميالي

  8. Main components of Computer System Output Device (s) Input Device (s) Processor (CPU) • Input Devicesأجهزة الإدخال • Output Devices أجهزة الإخراج • CPU (Central Processor Unit المعالج ) • Main Memory (RAM) (الذاكرة الرئيسية ) • Secondary Storage (Hard Devices) الخزن الثانوي Main Memory RAM Secondary Storage د.يحيى الميالي

  9. Computer Memory • Main Memory - scratch paper - Temporary • Secondary Memory - Disk Drives, USB Drives - Extended Life د.يحيى الميالي

  10. Main Memory • Random Access Memory (RAM) - bit Binary Digit - byte eight bits - Address 8 7 6 A D D R E S S 5 4 3 2 1 0 د.يحيى الميالي

  11. Computer terminology What is a computer? • A computer is a machine that is designed to perform operations that are specified with a set of instructions called program. • types of computer PCs (personal computers), microcomputer, workstation, mainframes, supercomputers Hardware Computer equipment - such as: the terminal, hard disk, disk drive, keyboard, mouse, and printer etc - PC (IBM), Macintosh, Sun ... Memory: the locations where the data may be stored and read (internal and external) • bit - the smallest unit of storage; is a single binary digit, 0 or 1 • byte - the smallest individually accessible unit of memory; consisting a number of bits, usually 8 bits to form a byte; • word- basic unit of data; its size depends on how many bytes can be read/write in a single instruction (This is what is meant by a 16 bit or 32 bit machine) (1.4 continue) .

  12. Computer system can be defined as a equipment that simulate the human being functions. It can manipulate data with high speed, High storage, and accurate results. A Typical Computer System from a Hardware Point of view as in the following figure CPU CPU . . . Memory Chipset I/O bus Cont. Cont. Cont. Cont. Cont. Mouse Network Secondary storage Devices printer Monitor

  13. High Speedسرعة عالية • High Cost كلفة عالية • Low Capacity سعة واطئة Register Cache memory Direct Referencing Memory Electronic Disk Magnetic Disk Indirect Referencing Optical Disk Magnetic Tapes Storage Hierarchy in Computer System

  14. Numbers Systems Decimal System System Digits ( 0, 1 , 2, 3, 4, 5, 6, 7, 8, 9 ), Base = 10 Binary System System Digits( 0, 1 ), Base = 2 Octal System System Digits ( 0, 1, 2, 3, 4, 5, 6, 7 ), Base = 8 Hexadecimal System System Digits( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F )

  15. Binary and Hexadecimal: (each group of 4 bits corresponding to a single hexadecimal digit) - example: B: 0001 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 H: 0 1 2 3 4 5 6 7 8 9 A B C D - Convert a binary string (9 bits) 110101101 to both decimal and hexadecimal: Decimal (power of 2 and add) 110101101 = 20 + 22 + 23 + 25 +27+ 28 = 1 + 4 + 8 + 32 + 128 + 256 = 429

  16. Hexadecimal ( Group of 4 and look up for corresponding digit) 110101101 = 0001 1010 1101 = 1AD • Binary and decimal: If one byte has 8 bits: 1) integer 0 = 00000000 and 255 = 11111111 2) If the leftmost bit is reserved for sign, and 0 for positive, 1 for negative, then -128 = 10000000 and +127= 01111111

  17. The Computer Brain • CPU - Basic Instructions - Add - Subtract - Multiply - Divide - Move things د.يحيى الميالي

  18. Software • Operating System - MSDOS, WINDOWS, Linux, Unix, VMS, Mac OS, and more ….. • Applications - Console, Web Browser, Office Programs, email client, Utilities, and much more … د.يحيى الميالي

  19. Programs/Applications د.يحيى الميالي

  20. HLL Assembly Machine Language Hardware Languages د.يحيى الميالي

  21. High Level Languages Examples - C / C++ - Java - Visual Basic - Pascal looks Similar to English Easier to write than Low level Language Must be translated or interpreted to low level language by the Compiler Abstracted from the Computer Hardware د.يحيى الميالي

  22. Low level Language د.يحيى الميالي

  23. د.يحيى الميالي

  24. د.يحيى الميالي

  25. Structured programming techniques. • Structured programming is a disciplined approach to writing programs that are clearer than unstructured programs, easier to test, debug and easier to modify. • Before writing program to solve particular problem it is essential to have a thorough understanding of the problem and a carefully planned approach to solving the problem. • The structure programming technique we are going to study here in this course are applicable to most high-level languages, including C++. • Any computing problem can be solved by executing a series of actions in a specific order. • A procedure for solving a problem in terms of: - The actions to execute and - The order in which these actions execute د.يحيى الميالي

  26. د.يحيى الميالي

  27. د.يحيى الميالي

  28. د.يحيى الميالي

  29. د.يحيى الميالي

  30. د.يحيى الميالي

  31. د.يحيى الميالي

  32. د.يحيى الميالي

  33. د.يحيى الميالي

  34. د.يحيى الميالي

  35. د.يحيى الميالي

  36. د.يحيى الميالي

  37. د.يحيى الميالي

  38. د.يحيى الميالي

  39. د.يحيى الميالي

  40. د.يحيى الميالي

  41. Spiral Model to Develop the Program Design Analysis V1 V2 V3 V4 Implementation Testing & Validation د.يحيى الميالي

  42. Pseudo code Pseudo code is an artificial and informal language that helps programmers develop algorithms. The pseudo code is similar to everyday English. It is convenient and user friendly, although it is not an actual computer programming language. Pseudo code does not execute on the computer. Rather it helps the programmer “think out” a program before attempting to write it in a programming language, such as C++. Example • To calculate the average of student marks in final examination we may write a pseudo code such as: Prepare student subjects marks For 1st subject1 to last subject; Add each subject mark to total Divide total by number of subject getting the average Print the average • The style of a pseudo code consists of characters so programmers can type pseudo code using any editor program. Pseudo code normally describes only executable statements – the actions that occur after a programmer converts a program from pseudo code to C++ or any HLL, and the program is run on a computer. د.يحيى الميالي

  43. ……………. Start/ Stop ……………. Processing operation ……………. Input/ Output ……………. Decision ……………. Predefined procedure ……………. File operation د.يحيى الميالي

  44. Start Declare variables I,n, mark , total An example of flowchart To calculate an average of n marks Read mark_i I=i+1 Add mark _i,to Total Yes Is i < n No Calculate: Average=TotalL/ n Print Average End د.يحيى الميالي

  45. Structure programming Constructs Start true Test false Statement-1 Test false true Statement-2 statement statement statement Statement-n End (b) Repetition (a) sequence (b) selection د.يحيى الميالي

  46. د.يحيى الميالي

  47. History of C++ C++ is a superset of C, which is a well-known and widely used programming language. C++ is a hybrid object-oriented programming (OOP) language. C++ is derived from the language “C with classes” which itself is derived from C and Simula 67. C is derived from BCPL which is derived from ALGOL 60. 1957 FORTAN ALGOL60 1960 1969 Simula 67 1972 C 1980 C with Classes 1990 C++ ARM 1996 ISO C++ د.يحيى الميالي

  48. Sample C++ program #include <iostream.h> #include <conio.h> void main ( ) { int x=0; cout<<“Enter value to X\n”; cin>>x; cout<<x; getch(); } د.يحيى الميالي

  49. Include directive C++ Program layout #include <iostream.h> #include <conio.h> Int main( ) { statement1 ; ….. statement n; return 0; } Every program must have main Statements are declared on each line in sequential order Terminates the program د.يحيى الميالي

  50. Sample C++ Program #include <iostream.h> int main ( ) { Variables Declarations ……. statement-1; statement-2; ……. return 0; { د.يحيى الميالي

More Related