Computer Programming By Prof.(Dr.) Anand K. Tripathi ,Mrs Monika Tripathi

Download Computer Programming By Prof.(Dr.) Anand K. Tripathi ,Mrs Monika Tripathi

Post on 03-Jul-2015




1 download

Embed Size (px)


Computer Science & Engg.


  • 1. Programming Language

2. Q. What do you understand by programming language? Ans. Programming Language: To write a computer program, a standard programming language is used: programming language is composed of set of instructions in a language understood by the programmer. Programming languages may be divided into three broad categories: 1.Machine Language 2.Assembly Language 3.High level Language 3. (1) Machine language: The language understood by machine is known as machine language. Programming is done at machine level. The vocabulary of computer consists of only 2 words 0 and 1, i.e. digits of binary number system where 0 indicates low voltage level and 1 indicates high voltage level. It is considered as 1st generation language. 4. Advantages: It can be directly typed and executed. No translator program is required. Disadvantages: Difficult to remember machine instructions. Difficult to understand modify and debug error. Difficult to remember addresses of data and instrument. Each and every information is numerical. Lack of portability program that runs on one machine doesn't run on the other. 5. (2) Assembly language: To overcome the drawbacks of machine level language. Scientists developed a new programming language which uses symbolic instructions. This symbolic instructions oriented programming language is known as assembly level language. This is Called second generation language. 6. Advantages: 1. Easy to remember operator codes. Easy to understand the program. Easy to write, modify and debug the program as compared to machine language. Need not remember addresses of operant (+,-,*) and instruction. Disadvantages: Not standardized. Less efficient than machine language. Memories are machine dependent. They differ from computer to another. 7. (3) High level language: It is totally machine dependent language. COBOL, BASIC PASCAL, ADA, C is all high level languages. The programs written in any of these languages can be executed on any machine. 8. Advantages: 1. Programs are portable. 2. Debugging is easier. 3. Most suited for software Development. 4. Programs are not machine dependent. 9. Q. Which was the first Electronic Computer? Ans. The first electronic computer was the ENIAC (Electronic Numerical Integrator and Calculator). 10. Q. Write the name of few different kinds of chips as used in computers? Ans. The following types of chips are used in computers. MEMORY CHIP C.P.U. CHIP MIRCOPROCESSOR CHIP Each of the above mentioned chips has special circuits designed to do the particular job. Memory Chips store the information others may work in the arithmetic unit. Some chips can do all the work which a computer is supposed to do and these are called as microprocessors. Such chips are known as Computer on a CHIP 11. Q. What do you understand by programming? How high level programming language is used for systematic development of programs? Ans. We know that that computer is only a machine which requires a series of instructions telling it what to do. The set of sequenced instructions which tell the computer to perform certain particular task is called a program. There are two types of program: 12. 1. System Programs: Programs that control and direct the operations of computer hardware are system programs 2. Application Programs: Programs that help the user and the system programs to work together are called application programs. 13. Definition of Programming: Programming is a technique of developing programs in order to achieve the desired goals using computers. 14. Methodology for Systematic Development of Programs for High level Language: A high level programming language must contain the following qualities for Systematic development of programs 1. A program should be correct and designed in accordance with the requirement laid out during the analysis of the program. 2. Program should be easy to understand .It should be designed in such a way that anyone can understand its logic. 15. 3. A program should be easy to maintain and update. 4. It should be efficient in terms of the speed and use of computer resources such as primary storage memory etc. 5. It should be reliable. 6. It should be flexible. 16. Q. Write the steps for designing and implementation of correct, efficient and maintainable programs? Ans. Designing and implementation of correct, efficient and maintainable programs is done by a systematic way of doing things. This consists of a set of guidelines, rules, concepts and practices which taken together are given the name structured programming. A good program can be developed by following recommended series of steps 17. 1. Defining the problem 2. Designing the algorithm 3. Coding the Program 4. Testing and debugging the program. 5. Implementing the program 6. Maintainable and upgrading the program. 18. Defining the Problem: It involves (i) Recognizing the problem. (ii) Identifying exactly what the problem is. (iii) Determining the available inputs and desired output. (iv) Deciding which configuration of computer is required to problem . computer. 19. Designing the Algorithm An algorithm is the finite set of step-by-step instructions that solve a program. After defining the problem,, algorithm can be designed by using design aids which are: Structure charts HIPO charts Pseudo code Flow charts 20. Structure Charts It is design aid in which the purpose of a module, the relationship to other modules and the overall program logic flow are shown. Each module (a small segment of a program) is represented by a box; 21. HIPO (Hierarchy plus Input Process Output) Chart: HIPO chart can enhance a structure chart by outline the input, processing and output needed by each module. With respect to above structure chart , HIPO cart is drawn: 22. It is a tool used to formulate the processing steps of a program. Pseudo code uses English phrases to describe the processing steps of a program or module. The logical control instructions within a structured design are emphasized in a pseudo code. Thus, the following logical control instructions arc always capitalized. 23. (I) PERFORM UNTI.. END PERFORM or DO WHILEENDDO These are used to indicate a sequence that will be executed until a specific condition is met. PERFORM UNTIL END PERFORM is a COBOL expression; DO WHILEENDDO is a FoxPro expression. 24. (ii) IF - - - THEN - - - ELSe.ENDIF This is used to test a specific condition. IF a condition exists THEN perform some operation; ELSE perform some other operation. Illustrations of the pseudo code has been discussed in detail in previous chapters. 25. Flow Chart: It is a design tool comprising of standardized symbols to show the components of a system or the steps in solving a problem. It is the most popular and commonly used design aid A detail of the flowchart has been taken in previous chapter. 26. 4. Testing and Debugging the Program: After coding, the program must be tested to ensure that it is correct and contains no errors. Three types of errors or bugs can be found which are; Syntax error Logic error Run-Time error 27. Syntax error: Syntax is a set of rules by which a programming language is governed. Syntax error occurs when these rules are violated while coding of the program. Logic error: This type of computer program error is caused by improper coding of either In-dividual statements or sequences of statements, It docs not stop program execution but gives wrong results, Run-Time error: This error in a computer program stops its execution. It may be caused by entry of Invalid data. The process of finding any type of errors mentioned above and correcting them is known as debugging 28. 5. Implementing the Program: After a program has been listed and debugged, it can be installed and implemented. Maintaining and Upgrading the Program: After installation of a program, it needs to be maintained for future use. A program once developed and implemented can be upgraded as per the requirements of the user. Maintaining and upgrading the program is an ongoing process. 29. Q. What do you mean by dumb terminal and smart terminal? Ans. A dumb terminal consists of VDU and a keyboard. It has no CPU of its own, and the processing is done only by the central unit. A smart terminal has its own CPU and peripherals also and therefore it is capable of doing its own processing at their end also. So smart terminal can also work independent of the central CPU too. The advantage of this feature is that some other OS can be loaded to its own hard disk and connection to UNIX can be established when required. 30. 1. Weight of the brain is about 1.5 kg. 2.The various parts of the brain like Cerebrum, Cerebellum, Medulla Oblongata etc. must stay together for its functioning. 3. Intelligence is rated as I.Q. the level of human intelligence various from 0 to 100. 4. The energy source is blood glucose. 5. It needs a steady temperature. 31. 6. It is assumed that computing elements in the brain are about a hundred thousand million. 7.The memory recall can be rapid or slow. 32. COMPUTER (1)Weight of the computer varies from a few grams to a few tones. (2)The various parts can be placed at different places. They can be linked by wires, satellites and laser beams etc. (3) I.Q. (Intelligence Quotient) is zero. It cannot think and whatever intelligence we feel it has it is actually on account of the efforts of the scientists and technocrats. (4) Electricity is the energy source. (5) It is less sensitive to heat or cold. (6) It has about thousand million basic computing elements and they are increasing day by day. (7) The access speed to memory is limited. 33. Q. What are the characteristics of high level languages? Ans. The following four characteristics are associated with the high level languages. (1)Machine independence. Machine independence means that a high level language could be used on any of the computer systems without making changes or at the most by making minor changes. (2)Use of a compiler. A compiler is a program, similar to an assembler, which translates the high level languages programes to machine language. Thus the translation work is done by the computer itself and the programmers are not taxed with this translation work. 34. (3)Self documentation. On account of this feature the syntax errors, the errors caused on account of improper use of high level language, are automatically pointed out to the programmers. This is done via an operational software. Once these errors are known then programs can be debugged. (4) Standard language format. The standardized language format provides level of uniformity to the language. Manufacturers do add special touches to standard versions to make them look attractive to the buyers. 35. Q. What is bugs and debugging? Ans. Mistakes in a program is called "bugs" and correcting those mistakes is known as "debugging". 36. Q. WHAT IS MACHINE LANGUAGE? Ans. The Machine Language is the language directly understood by a computer. In other words the binary language (the language of O's and l's) is the machine language. Any information or instruction in this language is to be represented in terms of O's and 1's. The symbol 0 standing for the absence of an electric pulse and I for the presence of an electric pulse. As a computer is able to recognize the presence or absence of an electric pulse, so it enable to understand the machine language. For example a sequence of O's and 1's such as 01110001 has a specific meaning for a computer, although it may appear as an ordinary binary number to us. This sequence may be fed to the computer by electric pulses in different time cycles 37. Q. What is word processor? Ans. Word processor is a microcomputer operating with special purpose software (e.g. WORD) which processes character strings. It is commonly used for office automation purpose for production of documents such as reports, letters, tenders, etc. Word processor accepts text as input which can be edited and laid out as desired. Word processors are usually equipped with a floppy disk drive and good quality printer. 38. Q. What do you mean by computer simulation and what is its purpose? Ans. In computer simulation mathematical model of the process/equipment under study is fed into the computer and the computer output represents behavior of the process under various operating conditions. Simulation is used to study the performance of system using a model and also for training purpose. Such models can be physical (as air plane placed in a wind tunnel) or mathematical (series of equations describing a system as a model of thermal power plant). 39. Q. Why was machine language discarded ? Ans. The writing of programs in machine language is very cumbersome and complicated task and it can be accomplished only by the experts. Machine language programming requires that all the information to be fed to a computer must be in numeric form and that too in binary language. Moreover, addresses of all the locations storing instructions and data must be known to the programmer and he should be able to address these locations correctly. Thus instructions stored in the computer in this manner are interpreted and obeyed by the computer. In other words, writing of a program in a machine language was a specialist's job and common man could not do it. This language was discarded due to these difficulties. 40. Q. What do you understand by bit, byte and word? Ans. A Binary Digit (BIT) (0 or 1) is called bit. One bit occupies one store location. A group or combination of 8 bits is called a byte. A computer word is a combination of one or more bytes handled together as one unit for processing and may thus be of 8, 16, 32 or 64 bite. The length of word varies from machine to machine but it predetermined for each machine. In some computers, the grouping of bite, bytes or words is flexible in design to meet the differing storage requirements of numbers, alphanumeric characters and instructions. A computer reads and processes all the bits of the word at a time. 41. Q. What do you understand by Programming Environment? Ans. Every one, who is ready to make a program, has to choose a programming environment that make to possible to create and run the program. Different types of programming environment is as follows: 1.Batch processing environment: 2.Time sharing Environment 3.Client Server Environment 4.Distributed Computing Environment 42. 1.Batch processing environment: In this programming environment data is collected over a period of time and then processed periodically. It is used for office work like accounts, salary etc. This type of environment is normally used with general purpose computers for applications, like preparation of bills, accounting jobs etc. However this environment is not useful with process control 43. 2. Time sharing Environment: This Environment provides the concurrent use of a single computer by many users....


View more >