Programming Language ● A programming language is a translator between human and machine. ● Machine language is a set of codes each consists of a binary string usually of length multiple of 8 (00000101,1000000,..) ● Since it is difficult to use binary codes we design programming languages. ● Each program language has a compiler which creates a machine codes.
Programming Language But Why use a programming Language? ● We can built powerful programs/algorithms, to make the computer do something we want to. But Wait, what’s an Algorithm, and how it can make the computer do something?
Algorithm Definition: ● A process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer. - Wikipedia ● A process with unambiguous steps that has a beginning and an end, and does something useful. - Wikipedia ● A list of steps that you may follow in order to achieve a goal - My definition
Algorithm - Daily Examples ● Faster Grocery Steps 1. Make a list of grocery shopping 2. Sort your grocery list by location in the store 3. Go to your favorite market 4. Get the grocery cart 5. Trace the best/faster route, based on your sorted list 6. Shop and Have fun
Algorithm - Daily Examples
Algorithm But how to apply for a computer ? ● Basically, it’s the same idea. You decide the steps, write it down, and ask the computer to execute the algorithm. ● But how can I write an algorithm and ask the computer to execute it ? ● As said it before, computers understand only 0 and 1(Machine language) ● We must use a translator, in order to “talk” to the computer
How to write this example, in English? 1. If need glasses: 2. Get some glasses 3. Then: ● collect ingredients and equipment ● Turn on your oven ● Prepare cake tins ● Prepare cream ● Put in the oven 4. while cake is not done(loop) ● keep it in the oven 5. Remove it from oven 6. Enjoy your Cake
Time to practice
How to Translate the Algorithm ● We are going to use C programing language
Recommend
More recommend