Table of Contents
Level: BBA (1st Semester) | Chapter-2: Programming Language
Subject: Computer & IT Application
For: PU (Pokhara University)
1. What is the machine language and why is it necessary to a computer ?
Ans: The processing unit inside the computer understand a language called machine language/code, and all the calculations that a computer performs use this code. Machine code which is ‘low-level’ language ,is specific to the particular made and model of computer on which it runs, and is designed to be read by human.
It is necessary because machine cannot understand human or high level language. Any instruction given to a computer must be translated (somehow) to machine code before the computer will understand it. It is unlikely we will ever need to come into direct contact with machine code. Typically, programs are written in high -level language that are easily readable by humans, but not by computers. they require compilers and interpreters to perform a translation into the machine code that computer can understand.
2. What do you mean by pseudo code? How pseudo code helps in real programming describe with example.
Ans: Pseudo code
Pseudo means false so pseudo code means false that only resembles a programming code. Pseudo code is a compact and informal high-level description of a computer programming algorithm that uses the structural conventions of a programming language but it intended for human reading rather than machine reading. It is an outline of a program, written in a form that can easily be converted into real programming statements. It cannot be complied nor executed and there is no real formatting or syntax rules. It is simply one step- an important one- in producing the final code.
Help of pseudo code in real programming
Pseudo code help in real programming as it enables programmer to concentrate on the algorithms without worrying all the syntactic details of particular programming. It is also used in planning of computer program development for sketching out the structure of the program before the actual coding takes place. It is easier for general person to understand than conventional programming language code so it is an intermediate language how to implement the code between client and programmer. For example a client wants result as if student obtained mark is above or equal 45 prints pass otherwise fail then it pseudo code is as follows:
- if the students grade is above and equal to 45
- print “pass”
- print “fail”
Its pseudo can also be
/*get the name of student mark*/
/*compare obtained mark>=pass mark(45)*/
/*if true, display pass*/
/*else display fail*/
Then this can be implemented by any programmer in any programming language or platform. Pseudo code helps a lot in real programming as it acts as intermediate language between client and programmer and helps in planning for programming in any programming language platform.
3. What do you mean by programming language? Describe different types of programming language.
Ans: Programming language
Program is the set of ordered instruction given to a computer to perform a specific task.
Programming language is defined as the rule of structure that should be followed to write any program. Programming language require information provided in certain order and structure, symbols and punctuation.
Types of programming language
Different types of programming language are:
i. Low-level language: These languages have been designed to give better machine efficiency that is faster program execution. Examples are machine language and assembly language.
- Machine language : The instructions are written in code which consists of 0s and 1s. Machine language is highly efficient and allows direct control of each operation. To write program in low level language, The programmer must be familiar with instruction set, available set of registers and computer architecture. They are machine dependent.
- Assembly language: Low level language where shorter form of a symbols called mnemonics, are used instead of 0s and 1s combination is called assembly language. The codes written in assembly language are converted to machine level by an assembler.
ii. High Level language: These language represent common language (English) used by humans or the language used by human beings for particular operations like in C. It is easy to use and learn. These languages have been designed to give better programming efficiency and machine independently. Further categorized as:
- Procedure oriented language: In procedure oriented approach, the problem is viewed as a sequence of things to be done. A number of functions are written to accomplish the tasks. The primary focus is on functions. Examples are C, FORTAN etc.
- Object oriented language : In this approach, problems are solved in terms of well defined objects. Each objects has some behavior and specific responsibility. OOL treats data as a critical element in the program development and does not allow it to flow freely around the system. It ties data more closely to the function that operate on it and it protects it from a accidental medications form outside function OOL allow us to decompose a problem into a number of entities called objects and then build data and functions around these entities. Examples are C++,java etc.
4. Write the algorithm and draw the flow chart o find smallest number among the three numbers.
Step 1: Start
Step 2: Ask three numbers a, b and c.
Step 3: If a<b and a<c then print a as the smallest number.
Step 4: If step 3 is false then compare as, if b<a and b<c then print b as the smallest number.
Step 5: If step 4 is false then print c as the smallest number.
Step 6: Stop.
5. Draw a flow chart to calculate the area and circumference of circle.