Q1: What is a computer language?
Answer: The instructions are fed into computers in the form of computer programs, follow some semantics (grammar or syntax) collectively is called a programming language. In layman terms, the language, which the user employs to interact with computer, is known as computer or programming language.
Examples are: C/C++, Java, Pascal, COBOL, Python, FORTRAN etc.
Q2: What are different generation of languages?
Answer: A good number of languages have been developed so far, therefore all computer languages are divided among different generations of languages:
- The first generation languages (1GL) are low-level languages that are machine language.
- The second-generation languages (2GL), ar also low-level languages that consist of assembly language.
- The third generation languages(3GL) are high-level languages such as C.
- The fourth generation languages (4GL) are languages that consist of statements similar to statements used in a human language.
- The fifth generation languages(5GL) are programming language based around solving problems following constraints-driven approach rather using an algorithm-driven approach.A good example of a fifth generation language is PROLOG.
Answer: Various problem solving approaches which were initially used in computer based solving and design of computer languages are:
- Look for similar patterns or situations (Table look up)
- Divide and Conquer
- Heuristics (rule of thumb)
(Hex View of .exe file)
Answer: Machine Language was the first generation programming language which is hard wired in processors. It is also referred as machine code or object code. Machine language instructions are built into the hardware of a particular computer. It is a collection of binary digits or bits that the computer reads and interprets. Machine language is the finite number of instructions that only a computer can understand.
Q6: What are the advantages of First Generation Languages?
Answer: Advantages are:
- Programs written in machine language execute very fast by the computer.
- The computer directly understands machine instructions, since no translation of the program is required.
Q7: What are the disadvantages of First Generation Languages?
Answer: Disadvantages are:
- Machine dependent: The processor and machine code are directly integrated the machine language differs from computer (processor) to computer (processor).
- Difficult to Code: Although, machine language programs are directly executed by the computer, but it is difficult to write program in machine language.
- Error Prone Coding: a programmer has to remember the machine codes, and must keep track of the storage locations of data and instruction. So it becomes very difficult to concentrate on the logic of the problem. This frequently results in programming errors.
- Difficult to understand: It is difficult to correct or modify machine language programs.
- High Cost of Maintenance: Because of tight integration with processor high chances of error coding, cost of coding and managing programs increase.
Q8: What is an assembly language?
Answer: Assembly language is a second generation programming language. Also referred as low-level programming language, it is designed for specific processors. Assembly language uses structured commands as substitutions called mnemonics. The mnemonics are used for bits used by machine language allowing humans to read the code easier than looking at binary.
A system software called assemblers were designed to convert mnemonic codes into machine language instructions. In general assembly mnemonic instruction consist of Opcode (CPU instruction) and operand (data value).
Here is an example of assembly language code.
mov ax,2C00h - Move number (2C00H) to AX register
inc cx - Increment value stored in CX register
int 20h - Call Interrupt 20H
Since mnemonics are one to one related to machine code instructions, assembly language is machine dependent.
Q9: What is a computer bug?
Answer: A computer bug is a any type of problem, defect or mistake in a program/software or in a hardware.
Q10: What is debugging?
Answer: The process of identifying and removing a defect in hardware or software is called debugging.
Q11: What are the advantages of assembly language over machine language?
Answer: As compared to machine language, assembly language has the following advantages:
- Easier to write code.
- Easier to debug program.
- Easy to modify program, reduce maintenance cost.
- Useful for writing small, real time applications for embedded devices.
Q12: What is an assembler?
Answer: Assembler is a system program which translates an assembly language code or program to machine code format. Generally assemblers are written by the manufacturers of processors because assemblers are machine dependent.
Q13: What are the limitations of coding in assembly language?
Answer: Following are the limitations of coding in assembly language:
- Machine Dependent: Since mnemonics are processor specific, one needs to port or translate his/her program while switching to another machine (processor model).
- Hardware knowledge is prerequisite. It because necessary to know about CPU and its hardware.
- Increase maintenance cost. Due to above said two factors, it increases the maintenance cost for managing software.
Answer: High level languages or 3rd generation languages use English like statements to code computer instructions. These are programmers' friendly since these languages are machine-independent and developers can concentrate on problem solving logic rather than on hardware structure. These languages require system programs called compilers (and interpreters) which translate English-like statements (source code) to machine code.
Examples of high level languages are: C, C++, Java, COBOL, BASIC, FORTRAN, Pascal etc.
Q15: Write full form of following computer language abbreviations
(i) COBOL: Common Business Oriented Language (used for developing for business applications)
(ii) BASIC: Beginners All purpose Symbolic Instruction Code
(iii) FORTRAN: Formula Translation (for developing scientific applications)
(iv) ALGOL: Algorithm Language
(v) LISP: List Processor (used for developing artificial language based applications)
Q16: What is a compiler?
Answer: Compilers are system programs, which translate a source code written in high level language to an object code. When a programmer writes a program code, he runs the compiler program, which translates it into an executable program. Then you run or execute the translated program.
In general compiler works in multiple stages. In the first stage it checks if the code follows the high level language grammar and semantics. If there is any error(s) it aborts the compilation process and reports the errors. If there is no error, it generates intermediate object code. In the second stage, linker which is a system program part of compiler, combines various object code files into a single executable binary file (machine code).
Q17: What is an interpreter? What are advantages and/or disadvantages the interpreter has over compiler?
Answer: An interpreter like a compiler is also a system program that translates a high-level language code into a low-level one. But the translation occurs at the moment when the program is run. A developer writes the code using a text editor or something similar, and then calls the interpreter to translate and run the program. Interpreter reads the source code one line at a time and translates each line and then executes it. Then it translates the second line, runs it, and so on.
The main advantage of interpreters over compilers is that a syntax error in the source code is detected and is brought to the attention of the programmer as soon as the program statement is interpreted.
The main disadvantage of interpreter over compiler is that it is slower than compiler when running a finished program. Also the interpreter's run time environment has to be available in the computer’s memory when the program is executed.
GW-BASIC is an interpreter for BASIC language. Visual C++, Turbo Pascal are compilers for C++ and Pascal languages. Now-a-days, modern languages like Java, C# use a mixed model of interpreter and compiler.
Q18: What are the main advantages of High Level Languages?
Answer: High Level language have the following advantages over using assembly and machine language:
- Machine Independent: A high level language written code can easily be ported to another hardware platform. Language instructions do not reply on characteristics of a machine hardware.
- Easy to Learn: Since the HLL instructions are English like statements, these are easier to learn.
- Closer to Design Process: The design process is better suited for HLLs as compared to low level languages. Implementing various programming techniques, algorithms and data structures is much easier in HLLs.
- Few Errors and Easy Debugging: Since the programmer need not worry about hardware instructions, he can concentrate more on developing program logic.
- Low development Cost: Writing programs in high level languages take less time as compared to coding in low level languages.
- Low maintenance cost: Programs are easier to manage. One can find errors easily and rectify them thus reducing the maintenance cost.
- Better Documentation: Since HLLs are English language statements and hence easier to understand. The code is self-explanatory and requires less commenting.
Answer: Although HLLs have numerous advantages over low level languages but it does have certain limitations:
- Large time to execute: A HLL translated machine code is bigger in size than low level programmed code. Thus HLL translated code takes larger time to execute.
- Less optimized code: Sometimes it is required to write a small sized efficient programs because of memory and performance constraints (e.g. embedded devices which use CPUs do not have large memory and need faster response). In this case, coding in assembly is better alternative.
- Managing Growing complexity is a challenge: As the code size of a software grows, the complexity to manage its code also increases. One needs to apply various disciplinary actions of software engineering and code management to produce a reliable software. This indeed increases the managing cost.
Q20: Who designed 'C' language?
Answer: Dennis Ritchie
Q21: Who designed 'C++' language?
Answer: Bjarne Stroustrup
Q22: Who designed BASIC language?
Answer: John George Kemeny and Thomas Eugene Kurtz at Dartmouth College
Q23: Who developed Visual Basic?
Answer: Microsoft Team
Q24: Who is known as Father of Computers?
Answer: Charles Babbage
Q25: Name the language which was named after a lady who was the daughter of poet Lord Byron. She worked with Charles Babbage to develop plans for the Analytical Engine.
Answer: Ada (and the lady was Augusta Ada Byron, countess of Lovelace. Also referred as the first known programmer.) Ada is a object oriented high level language.
Q26: What are fourth generation languages (4GL)? How are 4GLs different from third generation languages?
Answer: Fourth generation languages (4GLs) are English like statements commonly used to access databases. These are called command languages or non-procedure languages because these languages help the user obtain desired results without writing long program or procedures (as it is done in 3rd generation languages). 4GLs are more oriented towards non-technical users and reduce coding errors. Examples of 4GLs are SQL, DBMS, spreadsheets, FOCUS, report generator etc.
Q27: What are different types of programming errors?
Answer: Different types of programming errors are:
- Syntax errors: Mistyping a reserved word, e.g. typing peint instead of print
- Logic errors: e.g. A jump instruction that tells the computer to jump to the wrong address
- Arithmetic error: inappropriate use of arithmetic. e.g. divide by zero
- Runtime Errors: e.g. stack overflow, null pointer assignment, exceptions
Q28: Bugs are common in computer programs. Describe any two techniques which can be used to debug a program.
Answer: The two techniques which can help debug the program are:
- Trace Table (stack trace listing the functions called in a sequence)
- Reference of variables: Check the value of variable at various places of the program.