0% found this document useful (0 votes)
9 views

Programming Languages

About computer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
9 views

Programming Languages

About computer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 26
What is a computer Program? Oo A computer program is a sequence of instructions written using a Computer programming Language to perform a specified task by the computer. O These programs makethecomputer understand the user’s requirements, the function to be performed and the output to be given to theuser. Uses of Computer Programs Today computer programs are being usedin almost every field, household, agriculture, medical, entertainment, defense, communication, etc. a MS Word, MS Excel, Adobe Photoshop, Internet Explorer, | Chrome, etc., are examples of computer programs. @ Computer programs are being used to develop graphics and special effects in moviemaking. a Computer programs are being used to perform Ultrasounds, XRays, and other medical examinations. Computer programs are being used in our mobile phones for SMS,Chat, and voice communication. Why we need Programming Languages? ® Tn general you communicate with humans by using natural languages such as Sinhala, Tamil, English and so forth. If you want to communicate with a machine lie a Computer, you cannot use such languages. Language known as programming languages can be used to instruct computers. Different types of programming languages a Machine level language a Assembly level language a High level language Machine Level Language Q Machine level languageis the only language understood by computers. Q Programentirely consists of binary numbers (0’sand I’s). Q Machine language instruction hastwo parts. —Eg. 0000101 00001000 L Ly — Operation code: ‘Operand : ADD 8 Suchasaddition That identify the or subtraction data to be Q Computer program vwaitten lising any language should be translated to machine language before execute. Assembly Level Language Q Symbolic operation codes replaced binary operation codes. —Eg. ADDA: RepresentAddition a Assemblers convert assembly programs to machine code. a Easierto write. oocad High Level Language Instructions closer to everydayEnglish. It is easy to understand and write the program. Eg. BASICCOBOLFORIRAN,C Java, Visual Basic, etc. Following is a simple program written in C programming language. /* Hello World program */ #includecstdio.h> main() print#("Hello World"); Home work a Find out advantages and disadvantages of different types of programming languages. td cy ey hen Machine Level Language Assembly Level Language High Level Language Language Processors / Translators Computers can understand only one language. It is known as machine language. However humans are not familiar with the machine language. So you have to specify your idea using a high level programming language first. Then translate it into machinelanguage. Language Processors / Translators Q In order to convert the High level Language to Machine Level language, Language Processors are used. Q Language processors are two types. - Compilers - Interpreters Compiler Q Compiler translates the entire program code from the language it is written in, into machine level language. Q This process of conversion from text formatted program to binary format file is called program compilation. a If you are going to write your program in any such language, which needs compilation like C, CH, Java and Pascal, etc., then you will need to install their compilers before you start programming Computer Program File Computer Binary File Program Execution Interpreter a An interpreter translates program code to machine level language on line by line basis. Program Execution Difference between an interpreter and compiler eres ‘Transiate program one statement at a time. It takes less amount of time to analyze! the source code but the overall ‘execution time is slower. No intermediate object code (Binary File) is generated ores Scans the entire program and translate it as a whole into machine code. It takes large amount of time to analyze the source code but overall execution time is comparatively faster. Generates intermediate object code (Binary file) Continues translating the program Until the first error is met, in which caseit stops. Hence debugging is easy. It generates the error messageonly after scanning whole program. Programming language like Python, Ruby, PHPuse this Programming language like C,C+ use Compilers. Processing a High-Level Language Program Source program created with an editor Source code translated into machine language by compiler a Results in a .obj file (object code) Linker combines common library routines with object code Q Resultsin a.exe file (executable code) Loader brings executable code into memory and it is run Step 4 Step 2 Step 3 step step 5 Integrated Development Environment (IDE) An Integrated Development Environment (IDE) is a software application that provides a comprehensive environment for developers to write, test, and debug code. It integrates various tools required for software development into a single interface, streamlining the development process Example IDEs Pee ets Cand C++ Python a Code::Blocks, Dev-C++, Qdeveloper, MonoDevelop NetBeans, Bluel, Eclipse, Greenfoot, Jdeveloper, Xcode, Visual J++ Aptana,NetBeans.Kdevelop, PhpStorm ‘Erie, Wing IDE, Light Table, Kdevelop, Ninja-IDE Delphi IDE, Lazarus Components of a programming language a English has a predefined grammar, which needs to be followed to write English statements in a correct way. Q Likewise, most of the Human Languages (Tami, Hindi, English, etc.) are made of several elements like verbs, nouns, adjectives, adverbs, propositions, and conjunctions, etc. a Similar to that Computer Pro ing Languagesare also made of basicthree elements. Components of a programming language Q Vocabulary G Acollection of terms valid for the language. U2 It consists of preserved words provided by the language and user definedterms. a Syntax U Definesthe rules and guidelines for constructing sentences or instructions. a Semantics The meaning of the language instructions Steps to Develop a Program Q Developing a program involves steps similar to any problem solving task. Q There are five main ingredients in the programming process. «sDefining the problem «Planning the solution «Coding the problem «Testing the program «Documenting the program Defining the Problem Q Defining the problem consists of identifying what is known and what is wanted to obtain. a Eventually, the programmer produces a written agreement that, among other things, specifies the kind of input, processing and output required. Planning the solution a This is the stage where you decide how your program will work to meet the decisions you made during defining the problem. a In this phase you simply write down the steps in the correct order, that you are required to perform, to solvethe problem. a When all these steps are put together you have what is called anAlgorithm. What is an Algorithm? a Analgorithm is a complete step-by-step procedure for solving aproblem or accomplishing a task. a Algorithms canbe represent by using 2 Flowcharts. 2 Pseudo Codes. What is an Algorithm? Thefollowing isanalgorithm for makinga cupof tea. 1. Fillthe kettle with water. 2. Boil the water in thekettle. 3. Putthe teabag in acup. 4. Poursome of the boiled water into the cup. 5. Addmilk to the cup. . Add sugarto the cup. Stir the tea. Exercise Write algorithms for following problems. © Find some of two numbers © Find area of tringles and display it © Findthe largest from giventwo numbers and display the largestnumber.

You might also like