Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming Discrete Electronic Devices (C++) CETT 1331 By Khansaa Almansor.

Similar presentations


Presentation on theme: "Programming Discrete Electronic Devices (C++) CETT 1331 By Khansaa Almansor."— Presentation transcript:

1 Programming Discrete Electronic Devices (C++) CETT 1331 By Khansaa Almansor

2 What is a programming language? Programming Language is an artificial language designed to communicate instructions to a machine, particularly a computer. Human Language: Commonly used to express Feelings and to understand other person expression. It can be oral or gestural kind of Communication.

3 programming Algorithm: A set of steps that defines how a task is performed Program: A representation of an algorithm Programming: The process of developing a program Software: Programs and algorithms Hardware: Equipment used to input information (data) and output the results of the programs. Algorithm Program Programming Software Hardware

4 An algorithm is an ordered set of unambiguous, executable steps that defines a terminating process. Examples: while (tickets remain to be sold) do (sell a ticket) while condition do activity It is known in programming as a while loop

5 Program Program is Instructions that tell the computer what to do Programmer is Someone who writes computer programs

6 Example: Repeating structure Task: Write Hello 500 times. Programming Code Counter = 1 While (counter <= 500) do (print “Hello”; Counter = Counter + 1;) Counter 1 Hello 2 3 4 500501 Hello … Algorithm Counter equal to 1 While counter is less than or equal to 500, write the word “Hello” and add 1 to Counter otherwise stop.

7 Program is coding the algorithm “I want you to write on the chalk board, ‘I will not throw paper airplanes in class’, 500 times.”

8 History Timeline

9 Algorithms The word "Algorism", comes from the name Al-Khwārizmī (c. 780-850), a Persian mathematician, astronomer, a geographer and a scholar in the House of Wisdom in Baghdad, whose name means "the native of Kharazm", a city that was part of the Greater Iran during his era and now is in modern day Uzbekistan. He wrote a treatise in Arabic language in the 9th century, which was translated into Latin in the 12th century under the title Algoritmi de numero Indorum. This title means "Algoritmi on the numbers of the Indians", where "Algoritmi" was the translator's Latinization of Al-Khwarizmi's name.Al- Khwarizmi was the most widely read mathematician in Europe in the late Middle Ages, primarily through his other book, the Algebra.In late medieval Latin, algorismus, the corruption of his name, simply meant the "decimal number system" that is still the meaning of modern English algorism. In 17th century French the word's form, but not its meaning, changed to algorithm, following the model of the word logarithm, this form alluding to the ancient Greek arithmos = number. *Al-KhwārizmīHouse of WisdomKharazmGreater Iran Algebra algorithmlogarithm *wikipedia

10 Earliest true hardware The abacus was early used for arithmetic tasks to aid computation for thousands of years. What we now call the Roman abacus was used in Babylonia as early as 2400 BC. Since then, many other forms of reckoning boards or tables have been invented. In a medieval European counting house, a checkered cloth would be placed on a table, and markers moved around on it according to certain rules, as an aid to calculating sums of money.abacusRoman abacusBabyloniacounting house Several analog computers were constructed in ancient and medieval times to perform astronomical calculations. These include the Antikythera mechanism and the astrolabe from ancient Greece (c. 150–100 BC), which are generally regarded as the earliest known mechanical analog computers. Hero of Alexandria (c. 10–70 AD) made many complex mechanical devices including automata and a programmable cart. Other early versions of mechanical devices used to perform one or another type of calculations include the planisphere and other mechanical computing devices invented by Abū Rayhān al-Bīrūnī (c. AD 1000); the equatorium and universal latitude-independent astrolabe by Abū Ishāq Ibrāhīm al-Zarqālī (c. AD 1015); the astronomical analog computers of other medieval Muslim astronomers and engineers; and the astronomical clock tower of Su Song (c. AD 1090) during the Song Dynasty. *analog computersAntikythera mechanismastrolabeancient GreeceHero of AlexandriaplanisphereAbū Rayhān al-BīrūnīequatoriumAbū Ishāq Ibrāhīm al-ZarqālīMuslim astronomers astronomical clocktowerSu SongSong Dynasty *wikipedia

11 Jacquard loom The Jacquard loom was the first machine to use punch cards to control a sequence of operations. Did not do computation, but important in history of computer science. The ability to change the pattern of the loom's weave by simply changing cards – An important conceptual precursor to the development of computer programming. ( Check Wikipedia)

12 The Computer

13 What is a computer? Hardware & Software A computer is a electromechanical device which can be programmed to change (process) information from one form to another. – Do exactly as they are told. – Understand only two different states (OFF and ON)

14 Operating Systems Software Applications Software Software It is a program (Code) has been written using a programming language

15 15 Hardware Components Character ASCII CODE A 41H B 42H = = Z 5AH 41H A A 01000001

16 Applications Program’s Code (word.c) (High level language ) Compiler Assembly Code (word.obj) (Low level language) Linker Library (lib.h) Word.obj + lib.h (linked) Loader Application (Word.EXE)

17 Editor (C++ Program Code ) PreprocessorCompilerLinkerLoader Execution (Application) Library Syntax Error Run-Time Error Syntax Errors are errors of grammar while typing the program code. Logical or Semantic Errors are errors of meaning of your algorithm Run time errors are detected while the program executes. For example, entering string where program expect number Linking Error Linker Error means that your code compiles fine, but that some function or library that is needed cannot be found. Program Errors:

18 Editor where you type your C++ code Compiler of C++ language C++ file C++ code Output window for output comments such as Errors or warnings detection Line and Column numbers where the pointer is currently Project or solution name

19 Program Output Window Hello.EXE The cout instruction printing “Hello World” Press any key to continue compiler statement to show you the output and waiting to press any key to go back to the editor

20 I am electronic engineer. Why do I need to learn C++ programming language?!! Question?! Answer: Recently, Every device needs application on computer which let the user to use and control it easily. Answer: Recently, Every device needs application on computer which let the user to use and control it easily. Example: Printer To use printer you need not ONLY cables to connect it to PC!! But you need drivers and applications to be installed These applications and drivers have been programmed by C++

21 I am mathematician. Why do I need to learn C++ programming language?!! Question?! Answer: In many cases you need to calculate very complicated equations and for so many of times. Also, you need to save the data which has been calculated. So you need applications to do such calculations. Answer: In many cases you need to calculate very complicated equations and for so many of times. Also, you need to save the data which has been calculated. So you need applications to do such calculations. Example: Caculus C++ is one of the best programming languages to create such applications

22 Finally, to write good program you need to think logically while writing your algorithm. C++ Baby Logic : void main() { while (still_a_baby == true) { if (hungry == true) || diaper_needs_changing == true || wants_to_play == true || Just_feels_like_it == true) { End_sleep(); Start_cry(); } else { End_cry; Start_sleep; } Nice program !! C++ Baby Logic : void main() { while (still_a_baby == true) { if (hungry == true) || diaper_needs_changing == true || wants_to_play == true || Just_feels_like_it == true) { End_sleep(); Start_cry(); } else { End_cry; Start_sleep; } Nice program !! Example:


Download ppt "Programming Discrete Electronic Devices (C++) CETT 1331 By Khansaa Almansor."

Similar presentations


Ads by Google