Docsity

Algorithm and programming, Lecture notes of Algorithms and Programming

Toggle sidebar
bg1
International School of Management and Technology
Bharatpur-12, Chitwan, Nepal
Unit: Programming

Worksheet 1

1. How would you define a programming? Explain the necessity of programming
Programming is a technique to create a set of instructions in computer languages
including different steps in an organized way. In simple words, programming can be defined
as a process of telling a computer or a machine to do specific tasks by giving it instructions.
These instructions are called as programs. A person that writes these instructions is called as
programmer. The instructions can be of different languages also known as programming
languages.
A computer cannot perform an operation unless it is given instructions to do so. A
programmer must do the programming to be able to control the interaction between people
and machines. Programming helps inautomatingthe operations which aretime
consuming,error prone,repetitive,not person-dependentetc. They also assist in stream
lining the processes, provide better experience to the end users, keeping track of historical
data, analyze the data etc., Some programs are ridiculously costly and may take five years or
more with multiple teams engaged on it, while some might be relatively convenient and can
be created in matter of weeks by a single developer. An individual can Improve their
Programming Skills through Computer Programming.

2. Explain the different level of languages based upon the machine dependence.
Machine level language
Machine language is a low-level language which is composed ofbinarydigits 0 and 1. It is also
known as machine code. It is the only computer-understandable language without the need of
using a translation program. So, High-level languagesmust betranslated(compiled)into
machine language before running the codes on a computer device. Computers
aredigitalmachines, so, they merely recognize binary data. In the machine language, every form
of data like image, video, numbers, text characters are represented in binary form. The
pf3
pf4
pf5

Partial preview of the text

Download Algorithm and programming and more Lecture notes Algorithms and Programming in PDF only on Docsity!

International School of Management and Technology Bharatpur-12, Chitwan, Nepal Unit: Programming Worksheet 1

  1. How would you define a programming? Explain the necessity of programming Programming is a technique to create a set of instructions in computer languages including different steps in an organized way. In simple words, programming can be defined as a process of telling a computer or a machine to do specific tasks by giving it instructions. These instructions are called as programs. A person that writes these instructions is called as programmer. The instructions can be of different languages also known as programming languages. A computer cannot perform an operation unless it is given instructions to do so. A programmer must do the programming to be able to control the interaction between people and machines. Programming helps in automating the operations which are time consuming, error prone, repetitive, not person-dependent etc. They also assist in stream lining the processes, provide better experience to the end users, keeping track of historical data, analyze the data etc., Some programs are ridiculously costly and may take five years or more with multiple teams engaged on it, while some might be relatively convenient and can be created in matter of weeks by a single developer. An individual can Improve their Programming Skills through Computer Programming.
  2. Explain the different level of languages based upon the machine dependence. Machine level language Machine language is a low-level language which is composed of binary digits 0 and 1. It is also known as machine code. It is the only computer-understandable language without the need of using a translation program. So, High-level languages must be translated(compiled) into machine language before running the codes on a computer device. Computers are digital machines, so, they merely recognize binary data. In the machine language, every form of data like image, video, numbers, text characters are represented in binary form. The

binary data/machine code are processed as input by the CPU. The processed output is conveyed to the operating system or an application, which visually displays the output. Advantages The computer is fast and efficient to use with the help of machine language Machine language is directly understood by a computer so no translator program is required Disadvantages It is machine dependent as it differs from computer to computer. Programming and writing is difficult. Modification is difficult. It is vulnerable to errors. Assembly Language Assembly language is a low-level programming language that allows a programmer to provide instructions and data in human-understandable form which comprised of alphanumeric codes. The computer doesn’t understand the assembly language directly. So. in order to translate it to machine-understandable language, a translator program is required for converting assembly language to machine language called as an assembler. It is easier for us to remember and write in assembly language than machine language. Assembly language is readable by humans. Every assembly language varies from machine to machine i.e. every assembly is designed for specific computer architecture. Advantages It is hardware oriented. It is faster as it takes less time for execution. Making modifications are easier It is memory efficient. It isn’t necessary to keep tracks of the memory locations. It requires fewer instructions to get the output. Disadvantages It is very hard to remember all the syntaxes. It isn’t easily understandable. It lacks portability of program as it is different in every computer architecture.

then further translate it into machine language. Whereas some compilers may directly convert high level language into lower level language. Computer doesn’t understand any languages except binary language and it executes the program based on the binary language. Computer doesn’t execute a single instruction provided in any other language therefore. The provided instructions in any other language must be converted into binary form. That is where compiler comes into action. It takes instructions given in high level language and thus translates it in binary form. Compiler is like a bridge between programmers and computers. Interpreter An interpreter interprets supply code into item code one preparation at a time. It is much like a human translator translating what someone says into any other language, sentence via way of means of sentence. The ensuing object code is then done immediately. The method is referred to as interpretation. Interpreter is a translator program like compiler but its working mechanism is different from that of a compiler. Interpreter receives instructions in high level language and translates it into machine code. But it doesn’t execute a complete program at once. It converts only a section of our written program at a time rather than executing the entire program. It checks error in a program line by line. Interpreter takes instructions in high level language and converts it into machine code to make a program executable. Interpreter translates a source code line by line while the program is running. Using an interpreter, we can modify and evaluate a program during its execution. It is easier to use and more efficient than compiler. It does not target a specific computer architecture.so, it has advantage of portability. Assembler An assembler is a software that translates source language into machine language. It takes the fundamental instructions and operations from assembly code and converts them into binary code that may be diagnosed via way of means of a selected kind of processor. Assemblers are much like compilers in that they produce executable code. However, assemblers are greater simplistic considering they simplest convert low-level language to machine language. Since every meeting language is designed for a selected processor, assembling a software is done the usage of a easy one-to-one mapping from assembly language to machine language. Compilers, on the alternative hand, have to convert accepted high-level language into machine language for a selected processor. Many programs are written in high level codes and are compiled without delay to machine language the usage of a compiler. However, in a few cases, meeting code can be used to personalize capabilities and make certain they carry out in a selected way. A programmer if the use of Assembly language may want to have entire manipulation over their device and its function which Machine language cannot provide to its clients and getting to know smooth syntax is much less complex than getting to know numbers code and calculation addresses. Assembly language uses tons much less time which lets in in pace enhancement important to heightened overall performance and its performances and it

lets in the programmers to understand each education and strategies that take place and a programmer should recognize what she/he is doing. Assembly Language does now not require detecting the operand’s device cope with and the syntax can be represented with a photo due to which it is easy to visually understand the procedures. Even though Assembly language has a fewer kind of instructions and operations stays the best programming a person can ask for within the occasion that they want to investigate the set of policies and controlling of it