Unit - 3 Computer Programming After studying this unit the students will be able to understand; Computer Programming Language Computer is the combination of hardware and software. Hardware can be touched but software cannot. The existence of software can be felt when computer works with the active hardware. Hardware without software or program is lifeless, inactive. Actually software or program is the collection of some particular instructions. On getting the instructions, hardware performs the respective function properly. Computer does not understand the written and spoken language. It only understands if electricity is present or not. Computer can understand all instructions and accomplish all necessary functions depending on the absence or presence of electricity. This language is called machine language. In machine language the absence of electricity is regarded as 0 (zero) and the presence of it is considered as 1(one). It is very difficult for man to provide any instruction using with 0 (zero) and I (one). In the primary stages man had to do this difficult task for computer. Gradually men were able to frame some words similar to human language which computer can understand. Now Computer can understand the commands made by man-made language or artificial language. This language is called programming language. However, computer cannot directly understand the programming language. A translator is used to transform commands written in program language into the machine language of computer. This translator is called complier or interpreter. Division of Programming Language Computer programming language can be divided into three classes. For example Machine Language Assembly Language High level Language Besides these divisions the computer programming languages are again divided according to generation. Generally the language of second generation is more powerful and easier than the language of the first generation. In this regard, machine language is considered as the language of the first generation and assembly language is second generation language. At present, the age of third and fourth generation is going on. Man is now thinking more about the use of man-made intelligence for computer and the language of fifth generation will be used to achieve the goal. Machine Language Machine language means the language of machine. So, the language computer can understand is machine language. This is the absence and presence of electricity. Computer can understand the
commands written by 1 (one) and o (zero). A user gets the result of his work on the monitor connected with the computer. However, computer performs functions from the beginning till the outcome according to its own language written by one (1) and zero (0) or binary system. But it is very difficult for man to send all kinds of commands and input to computer in binary system. Moreover, it takes much time and efforts to type too many numbers. Assembly Language There are some problems to create and assemble the programs in machine language. To lessen the difficulty in creating and assembling process assembly language has been developed. For example, to ask the computer for addition in machine language or in binary system, 10000101 is to type. In assembly language, however, at first ADD is type directly then the command for addition (+) can made computer understand by computer instantly. Translating the ADD command into 1000101 binary signal can make understand that the command for addition has been given. This translation is done by the software namely Assembler. The function of assembler is to translate the command written in assembly language into machine language or binary signal. The programms written in assembly language can be changed. It takes less time to write program in assembly language than to write in machine language. However, there is some limitation in assembly language. For example, assembly language is machine dependent. Assembly language differs from computer to computer. As a result, it requires a lot of training to know how to use assembly language. Again a man who can write programme in assembly language in a computer has to learn the assemble language anew to create program in another computer. To overcome the difficulty both in assembly and machine language High Level Language has been developed. High Level Language Machine language and Assembly language are regarded as low level language. On the other hand, the programming language of BASIC, C, C++, Pascal, FORTRAN, COBOL etc are called High Level Language. These are also called the language of third generation. In High Level Language man's understandable language can be used. In high level language we can use some English words, sentence in programming as we use them in expressing a particular meaning. Compiler is used to transform high level language into machine language. Sometimes compiler or interpreter software is used to translate these languages. So, by using compiler and interpreter we can use any programs written in high level language to any computer. Some advantages of high level language are mentioned below. 1. Program in high level language can be created by using words used by man. As a result, high level language can be learnt easily than machine and assembly language. 2. High level language is not machine dependent. The program in high level language can be used in any computer without any change or by little changes. 3. It takes less time to do programming work in high level language. 4. Mistakes in program in high level language can be identified easily and can be corrected changing one or two letters or lines. On the other hand, it is very difficult either to identify problem or to correct them in machine and assembly language. Translator program: The program which transforms high level language into machine language is called language processor program. If there is no mistake in the statement, grammar, syntax etc of the programs in high level language, the language processor program transforms the language into machine language.
The transformation of high level language into machine language is called translation and language processor program is called translator. Translator program are of two kinds - Compiler Interpreter Compiler At first compiler examines the program in high level language from beginning to end. The compiler directly transforms the program into machine language, if there is no mistakes. In this case the program written in high level language is called source code and the program transformed in machine language is called object code. After transforming into machine language the program in high level language is saved in the memory of computer and functions the program as object code. The program transformed by compiler can be opened or activated as many time as you want. For every programming language there is separate compiler. The compiler of one language cannot translate the language of other language. Interpreter Like compiler, interpreter is also a translator program. Interpreter transforms high level language into machine language. However, the process of translation is different. It interprets step by step. After the translation of a line into machine language and after completing the assembly, it starts for next or another line. In the same way interpreter, translates, transforms and assembles one line after another separately from the beginning to end of the program. Interpreter stops if it finds any mistakes in any line. After the correction of the mistakes it translates, transforms and assembles. This program continues till the last command of translation, transformation and assembles. Comparative relation between compiler and interpreter Compiler transforms the whole program into machine language at a time. As a result, all the mistakes and types of mistakes anywhere in any line are displayed at a time. On the other hand, interpreter transforms into machine language line by line, any mistakes in any line are displayed instantly and they require instant correction. It is not necessary to transform a program into machine language by compiler again and again. Once the program is transformed it can be used as many times as needed. However, whenever it is necessary to work with the program once transformed into machine language, it is to transform the program newly again into machine language. Compiler functions speedily whereas interpreter functions comparatively in less speed. Different stages of making composing program While making composing or using program, the program composer or users should be careful about composing and using a program. There are four stages for composing a complete program correctly and after completing the stages, the composing of programs starts. The stages are: Identifying the problem and analyze them Making flow chart Writing code Debugging Identify the need or problem and analyze them Computer program is first written on paper. The main intention of a program is to reach a satisfactory solution of any need or problem. So, the first target is to identify problem or need. Suppose the obtained marks in mathematics of class IX students of a school- Jamal, Kamal, Hassan, Kasem and Habib have been declared. Those who scored less than 40 failed in this subject. In the circumstance, the identified problem is to find out who have passed and who have
failed. The necessary information or data for the solution of this problem suppose the obtained marks by Jamal, Kamal, Hassain, Kasem and Habib are 33, 70, 40, 65, and 38 respectively. Decision list should be made on how to compose and activate program and how will be the sequential stages. These decision making lists are called Algorithm in programming language. Algorithm is a well processed system of solving any problem. This system can be used for writing program in computer. For example, it is a system of finding a big number out of many numbers Flowchart: Flowchart is the drawing of the stages of algorithm. The main purpose of flowchart is to present picture form on how and which way the stages of program is flowing. Flowchart is formed based on algorithm. About forming the flow chart always bear in mind Every command does not need to involve in flowchart and stage of algorithm may not be included to flowchart too. Therefore, the flowchart should be formed independently so that, flow can be understood seeing it at a glance. As many stages can be followed to meet the need, so many opportunities are there to follow to form a flowchart. So, the main aims of a programmer is to form a perfect flowchart. But it is not mandatory for all the time. Flowchart should be irrespective of program. The same flowchart can be used by any programming language. Flow chart should be so far simple and direct. Unnecessary loop and branches should be avoided. Only the statement should be included in flowchart. Commands such as data, remarks are not activated while assembling the program. So commands are not included in flowchart. Flowchart is program based. So, if there is any change in program, at first flowchart is re- arranged. The transformation of the theme of flowchart into language of computer programming is called coding. Pseudo Code Pseudo is a popular system of composing and developing program. It is a Greek word which means disguise. In programming Pseudo code does not mean actual programming. Pseudo code is the collection of statement/command to show the types and activities of programs. Regarding the example of algorithm the act of going to school from house can be divided into three or four ways. Pseudo code is made before making the actual program or final algorithm. If necessary, more than one code may be made. For finalizing the algorithm, pseudo code is prepared one after another. Debugging After writing a program it takes a lot of time for debugging. The significance of errors in a program are:- Syntax Error Logical Error Execution Error Carrying out a program is not possible in the presence of any of these error. Syntax Error Syntax error is generally occurred due to typing mistake, for example PRIMT is mistakenly typed in place of PRINT.
Not using equal sign (=) in LET statement is regarded as syntax error. Using a mathematical sign to the left of equal sign (=) in Let statement is regarded as syntax error too. Not using necessary quotation (\" \"), semi-colon (;) and coma (,) in PRINT statement is considered to be syntax error. To correct error is easy. When correct sign is typed erasing error sign, correction is done. Execution Error Execution error is the secondary error. This error is noticed when program runs after debugging. Computer displays error message and code number when any execution error is found. Execution error is found, for example, when a variable of zero (0) is divided by a variable and the number of digits is accessing to numbers acceptable of a computer. Execution error does not allow the error of using the neutral variable is carrying on a program. Computer directly identifies the syntax error. As a result, correction is very easy. However, execution error cannot be identified so easily. So, the correction of execution is very difficult. Logical Error After completing program execution unexpected result may occur from logical error. One of the noticeable reasons of logical error is that if print command is not given on completion of execution program, no result will be displayed. If wrong data is sent, naturally the result will become wrong. Some necessary words or terms of Programming Language Constant Constant is a meaningful name that holds unchanging mathematical values. In the program where this name is used the name is substituted by its mathematical value. The user can declare any word as constant. These declared constants are called user-defined constants. Variable Variable is a preserved area in the memory of a computer where data or information is saved temporarily to use next time. Both the program developer and user work with various information. Users can send information/data for the need of the program. Actually, what variable contains is a unknown subject. Suppose an egg seller needs software for his shop. Eggs are not sold in the shop at a fixed rate. So, it is unknown that how many eggs on what rate will be sold. In this case variables are used to store the unknown values or prices. The name of the variables is Egg price and Egg sold. Each time when egg is sold, the users of the program will provide values for two variables. Calculating the entire selling amount computer will display total amount in the text box. Every variable itself has a name, data type and value. The value of variable is not unchangeable like constants. The value of variable changes again and again. Changing of value is the characteristic of variable. According to rules any name can be given to a variable in English letter or number. However, at the beginning of a name number cannot be used. The number of letters cannot exceed 255 characters. The name can be used in small or capital letter. No full stop (.), comma (,), colon (:), semi-colon (;) or any special character and space can be used in any name. Only under- score can be used. Data Type The programmer has to decide earlier in which case how much information should be used. For writing someone's age three letters may be enough. However, memory will be misused if 100 letters is used for a name. Different kinds of data types are used in Visual Basic for determining the amount of space preserved for particular information. Data Type Range Size 1. Byte 1 Byte 0 to 225
2. Boolean 2 Byte True or False 3. Integer 2 Byte -32.768 to 32.767 4. Long (Long Integer) 4 Byte -2,147,483, 648 to 2,147,483,647 4 Byte For negative value-3.402823B38 to floating- 5. Single (single-precision) point) 1.401298B-45 8 Byte For negative value- 6. Double (double- 1.401298B-45 to 3.402823B38 precision) 8 Byte For negative value- (floating-point) - 1.79769313486232E308 to 4.94065645841247E- 7. Date 324; Fornegativevalue-4.9406545841247E-324to 1.79769313486232E308 January 1.100 to December 31,999 Every data type preserves different types of data and at the time of declaring variable, data type are selected according to capacity of data storage. Type Mismatch or Overflow Error After the declaration of variable, the data types which are concerned the same data must be used next time. For example, after concerning the integer data type with any variable and text is used as value then it use display error. So, the data types which are concerned with the variable should submitted as the value of variable. If another value is used their type mismatch or overflow is displayed. Property, Event and Method Property, event and method are the basis of any object oriented programming. Actually, at the root of each visual basic application there are property, event and method. Property Property is the characteristics of any object which expresses the and condition behavior of the object, for example, form is an object. Generally, its size, its name, caption, place, color are all its property. The concerned properties of any object are found in properties windows and their names can be changed. But there are some properties which are not found in properties windows. They are selected from code window. Event There are event-driven and graphical user Interface programming environment in windows operating system. It is easy to create windows based program using Visual Basic. This is because; visual basic can significantly overcome the difficulty of windows basic programming by procedure. Event is an action which takes place by control when visual basic is going on. In a form, which object or control will work is decided by event. User presses on a button of keyboard or clicks mouse button while a program is going on. These actions of a user are called event. Method Method is some internal procedure of visual basic which is effective with some particular objects. Therefore, the objects which are used while developing a program, some necessar y methods can be used with them. There are some particular methods in every object. They are pre-defined even the activities are early decided. The function of program is to know which
method will work in which project and to use them when necessary. Programmer cannot change the functions of any methods. Reserved Word There are some words in visual basic which are preserved for particular function. These words are called reserved words. Some important reserved words in visual basic are All, As Asc/Desk, Binary, By, By Ref, By Val, CREATE, Data, Drop, Else, Employ, Error, False, For, Friend, Get, In, Index, Input, Into, is, join, len, let, lock, Me, Mid, New, Next, Nothing, Option, Optional, Patern, Array, Print, Private, Property, Public, Resume, Seek, Select, set, static, string, table, Time, To, True, With, With Events. Starting Program There are some processes generally to start application program in computer. Following any of these visual basic can be started. After clicking start menu to the left of the taskbar a pop-up Menu appears. Place the mouse pointer on the programs. Different kinds of folders lists of application can be found to the right. Select and click Microsoft visual studio 6.0 > Microsoft visual Basic 6.0 and it will be opened. The above mentioned system can be followed step by step to start visual Basic 6.0. At a certain stage, new project window appears where three tabs New, Existing, Recent tabs are seen. New tab remains as default. To open the previously created project click on Existing tab and to open any recently used project click on Recent tab. There are many projects in New tab. Of them standard EXE is the first project and it remains selected as default. This project is used to create any application program. Any of the following actions is to be accomplished for this. Double click on the standard EXE. Click open button while it is selected
. Project Microsoft Visual Basic mode is displayed. This is called Project Development Environment (PDE). The programming environment of Visual Basic is formed with some window and option, for example, application tool bar, Menu bar and standard toolbar. Project -Format (Form) stands on the middle of screen on which window without scroll bar is seen as default name. Form -1. Setting up the graphical elements on it, graphical user interface is created for programs. These graphical elements are also called control. To the left side of the toolbar is tool box. In this toolbox there are different kinds of controls. Project Explorer and properties are displayed to the right side of the window. Moreover, if necessary, form layout can be made appeared and placed under the properties of window. Window generally does not stand on screen for writing window code and division. Code window appears on the window screen just after the double on form or any control. Shutting down Program
After opening the program it is necessary to shut down at a certain time. Select Exit command from file Menu to shutdown /close Visual Basic. The fundamental themes of Visual Basic: The Project Development Environment and other options are necessary for creating application program. We can discuss this first. Some other subjects are also discussed in this chapter, but they are not necessary for creating project with Visual Basic. Menu bar There is a Menu bar in every windows application programs. So is in Visual Basic. According to application there are some visual differences in the Menu. They are different from each other based on their functions of application program and the ability to work. After Visual Basic begins is a horizontal bar containing Menu below the title bar is called Menu bar. There are File, Edit, View, Project, Format, Debug, Run, Query, Diagram, Tools, Add, Ins, Window and Helper on visual basic Menu bar. Toolbar Another vertical bar below the Menu bar is called toolbar. This toolbar is called standard toolbar. The standard toolbar stands below the Menu bar as a default. There are some tools on the toolbar by which some necessary command can be activated very easily. Window and form We can work using some necessary projects from the dialogue box of new project. Work starts by standard. exe while creating new program. Select standard exe from project dialogue box and then click OK button project window will appear. This project window is the field location/area for creating Visual Basic program and all the activation are done for creating a new application under its control. In the project window a window is displayed name from 1. It is called Form. Based on this form Visual Basic program interface is created. After completing the primary activities when the program is run it transforms into a window in which options like title bar, menu bar may be found. Control and Toolbox Control is the particular type objects of Visual Basic. By setting control on form an interface of application program is created, for example, text box, check box, combo box, command button, option button scrollbar etc. These boxes and buttons have significant role in designing program. Of them, program interface can easily be made by visual basic. The toolbox of the Visual Basic is known as control. To create interface of program, select control from toolbox and set on the form. Any one of the following process can be performed for setting control: 1. Click twice on a particular tool and it will be inserted the centre of the control form shaped like default. The more double click you give on a tool, the more control form will be inserted. They can be replaced or shapes can be changed or other features, if necessary. 2. Click and drag a selected tool according extension of the drag a control will be set up. Any kind of control can be setup at the beginning of this process. The shape of the control can be changed by clicking and dragging the handles by mouse pointer around the selected control. It can also be done by properties window. N.B. Drag means pulling an object by mouse pointer to change its size or shift its position. The shape of a control can also be changed with them. Moreover, control replacement, lock-unlock and permanent of their position can be done by mouse, keyboard, command Menu. The process of changing shape of a control is described below: Click control with mouse and select and see handles are displayed.
Drag and click on any handles by mouse pointer. Release the mouse when desired shape appears. Or Pressing shift key you can select shape and size with the arrow key of key board. Change the height and width of window properties according to the need of property value. For replacing the control any of the following action can be performed. Click and drag control and then replace or transfer the control from one place to new place of the form with the mouse, change the value of left and top property from properties window to change the control. To transfer a control use Arrow from keyboard pressing Ctrl. One grid of unit can be changed by pressing arrow key one time. Some default tools in toolbox Pointer This tool is used for selecting an object. If any object is selected with the tool a rectangular box appears around the object which are called handle. Click any of the handles and drag to change the shape of the object. Picture Box Picture box tool is used to set a picture on the form. Label This tool is used to set any label to identify or to write other necessary captions of any objects. Text Box The text box which is used to write and edit text in the box when the program is going on. Fame This tool is used to bring the controls of forms in a group. Comma and button This tool is used to create command. For example; OK, Open, Cancel in a window are command buttons. Check Box To create a check box this tool is used. Option Button The round/circle buttons which are made by this tool is generally called radio button. Combo Box Combo box is made by this button. Click a triangular box to the left of combo box and a list will appear and then select any one from it. H Scroll Bar If you want to see too many information on window side by side, this tool is used to create horizontal scrollbar control. V Scroll Bar If it is necessary to see too many information top to bottom, this tool is used to create vertical scrollbar control. Time Timer can be created to correct time or to set any information based on about time. Drive List Box This tool is used to create control to show the list of disc drive. Favorable drive can be used to work from the long list of drives.
Dir List Box This tool creates a control to show the list of folder. File List Box To show the list of folders in the folder a control is made by this tool. Shape This tool is used to draw square, rectangular, circle semi-circle, angle etc. Line This tool is used to draw different kinds of lines. Image This tool is used to bring/import any image on the form. Data This tool is used to draw a database control by which data can be imported from data source. OLE This tool is used to link or embed an object. How to Lock or unlock Control The controls in form can be locked. After locking no control can be transferred or reshaped. Controls form can be locked or activated by following the process described below. Select Lock controls from format. Click lock controls toggle from edit toolbar form. The commands for locking above mentioned commands are a toggle command and by using the same command it can be unlocked. Properties window To draw a project in the Visual Basic different kinds of objects are used. Objects are the components used in project, for example, form, control etc. These objects have many general features and particular features. In Visual Basic language there are features called properties and where these features or these objects are displayed is called properties window. Some features or objects which properties window generally display with their full name or short name are shown below:- Object's full name Short name Object's Full name Short name Combobox Cbo Checkbox Chk Commandbutton cmd Directorylistbox Dir Image Img Label Lbl Picturebox pic Resource Res Textbox txt User-defined data tYP Sometimes the short names are used in properties window and other places. For example, img for image, pic for picture box, text for Textbox etc. In the beginning of properties window the title can be seen. In an object box there is a list of objects used by any active projects. This object box is actually a combo box. These select the list from the box and then properties window display that features of the selected objects. Form Lay-out window
Form is the main element for the users of Visual Basic graphical interface. To decide where on the computer the form will be displayed, there is a window named form layout window in Visual Basic. If it is not present on the screen select view > form layout. It will be displayed. Its location can be changed with the tool of point click on. Then line merge on form layout window to transfer any place. After that, when the form runs, it is displayed on the monitor. Immediate Window Debug window is known as immediate window in Visual Basic. The main function of the window is debugging. Debugging means a system of looking for mistake occurred while writing program code and correct them. Type any statement of visual basic and press its button. Instantly, the result is published on the window. Moreover, debugging can be done by this window while the program is going on. If this window is not present, select view>Immediate window> or command Ctrl + G. The usage of mathematical, relational and logical operator Sometimes a data need some addition (+), subtraction (-), multiplication and division. Sometimes one data is needed to compare with another programming language, some signals are used to do these in Visual Basic. These signals are called operator. In main Visual Basic three kinds of operators are used. For example:- 1) Mathematical Operator 2) Relational Operator 3) Logical Operator Mathematical Operator Addition, subtraction, multiplication, division etc used for mathematical functions are called Mathematical Operator. For example:- + (Addition): This operator is used for addition for example: 4+3=7 - (Subtraction): This operator is used for doing subtraction for example: 4-3=1 * (Multiplication): This operator is used for multiplication, for example: 4*3=12 (Division): / This operator is used for division especially when the quotients are in decimals, for example:4/3 = 1.3333333333 Integer Division: If it is used for division the quotients are complete number, for example: 4/3 = I Mod: This operator is used to find reminder for example: 4 Mod 3=1 Relational Operator In Visual Basic some operators are used to compare between two similar factors which are called relational operators, for example: < Less than > Greater than = Equal to <> Not equal <= less and or equal >= Greater or equal to Logical operators are used to separate between two things True or false. The logical operators of visual basic are:- And operator Not operator Or operator Nor operator Moreover, other kinds of logical operators used in basic for example: Eqv Operator
Imp Operator There are some commands regarding input and output for receiving the information from the users and after activating that information, to send the result in visual basic. Of these commands, the main is function and on procedure. By using these signals input and output are activated. Input Box is for activating input command and MS Box are used to activate the commands regarding output. Input Box Function This function is used to take any information from the users. A dialogue box displays this function and there are a prompt, an OK command button, a cancel button and a text box. Help button may be displayed according to the arguments. The syntax of these function are :- Input Box (prompt, title, default, Xpos, Spos, context) After sending the necessary information to the text box, if the user click OK button or Enter, the result of the analysis appear in input Box. And if the user click cancel button the dialog box will disappear from the screen. Msg Box Function Input function is used to take any input/instruction from the users. Another function of it is to send output after analyzing the information. This output function is done skillfully by Msg Box. The syntax of the function is Msg Box (Message, Button, title, and helpfile context). Array and Function Array is a kind of variable. Its specialty is that a good number of data can be stored in the same name, whereas in general variable one data can be stored in one name. Like variable, at the time of declaration of array its name and data type is declared. The syntax of array declaration is given below: Dim Array_.name (range) as Data type. Range is written in the bracket of array name. Except this part, other things are written like variable. The main difference between variable and array is the declaration of range. Writing number for range in the bracket 0 after array's name decide the number of elements in any array. Function Function is a part of Visual Basic code which by itself receives information and gives result or value after analyzing them. For example: Aqr 0 is visual basic function. This function is used to find the root of a positive number. The value of the function that displays a number is called Return value. There are various functions for getting the results of visual basic. A very important function of Visual Basic is input or output function. We have discussed earlier about the commands of function of input and output. Some important functions are discussed below: Val () Function: This function is used to transform number into string and the syntax of this function is val (string) Date Function This function is used to know the present date. The syntax of this is Date. Time 0 function This function is used to know the time in AM/PM format and the syntax of this function is Time O. Now Function
To know the present data and the present time in AM/PM this function is used. The syntax of this function is Now 0. Month 0 Function To find the number of days from date this function is used. The syntax of this function is Month (Date) Year 0 function To find the number of year from date this syntax is used. The syntax of this function is year (Date) Summary Different types of Application programs are found for different kinds of work is done by computer. However, there are many works which cannot be completed by applications. To do these works specific application program is to be develop. Program is developed using different kind of languages. The language of programming can be divided into Machine Language, Assembly language and High level language. Machine language is the language of computer. There are only two letters, (o) and one (1). The calculation system by these two letters is called binary system. Computer does not understand any command except this binary command. However, it is very difficult to create command for all kind of work by binary system. A large number of binary numbers are used to write a few words or number. Machine language is not used to develop program. To overcome the problem in developing program by Machine Language. Assembly Language was developed. One problem for this Assembly Language is its dependency on machine. The Assembly Language for computer varies from one computer to another. The Assembly Language of one computer cannot be used by other computer. To overcome the limitation of Assembly Language there are some high level Languages - BASIC, Pascal, FORTRAN, Cobol etc. So, compiler and interpreter software are used to transform the high level language into modern language. This solution is called Algorithm in programming language. The line of drawing of the algorithm is called Flowchart. Flowchart is program based. The process by which the theme / subject of flowchart of computer is transformed in programming language is called coding. Developing pseudo code is a very popular process. It is a Greek word. The word Pseudo means \"disguise\" or \"not true\" while programming Pseudo code does not mean actual griming. A. Collection of statement or to show type of function of program is called Pseudo code. Pseudo code made before creating the main algorithm. Sometimes more than one Pseudo code is created. John Kemeny from Dart- mouth college and Thomas Kurtz invented basic programming software in the middle of sixty. Since the middle of seventy decodes the institution of micro computer manufacture used this basic as standard language for computer programming. American National Standards Institute (ANSI) standardized the necessary parts for the uniformity of different reformation of basic in 1978. Microsoft Corporation a famous software producer brought out the visual basic in 1991. Programming difficulty has lessened to some extent after the arrival of visual basic. A program can be developed in the shortest time by using few words in this visual atmosphere. There is a strong integrated developed environment in visual basic. It is a program environment approved by all and it can work and move by itself very quickly. Any kind of application program can be developed using Visual Basic programming Language. Exercise
Multiple choice questions 1. To write a complete and error-free program, the most necessary tasks are- i. to identify and analyse the program ii. to create the flow iii. debugging and coding Which one of the following is correct? a. i and ii b. i and iii c. ii and iii d. i, ii and iii [The following paragraph is applicable for questions 2-4] Students are asked to perform a project for a school library in Visual BASIC 2. Which command will the students use to declare the variable? a. Print b. Msg Box c. CMD d. DIM 3. What type of translator is suitable to use for time saving? a. Compiler b. Interpreter c. Assembler d. Debugger 4. A program written in Visual BASIC is called- a. Source code b. Object code c. Unicode d. ASCII code Long Questions Look at the picture What is indicated by the flowchart? Describe the function of the cell IS=A+B+C+D+El used in the flowchart. How can the above cells be used to find the sum of the series 1+2+3+ +N? - Describe it. Analyse why the flowchart is very important for computer programming.
Unit - 4 Word Processing (Microsoft Office Word 2007) After studying this unit the students will be able to understand; Word processing means typing with computer. We are familiar with ink, pen and paper. We use to do our work of typing with them. In school, college or university we use ink, pen and papers for writing. Typing is performed by word processing program in computer. Computer made a huge change in the sector of printing and publication. In previous time we did the printing job through many phases of tedious works. But now it has become very easy because of computer. The previous printing system would require a lot of time and money also. Sometimes the printing would not be so clear. As a result, it was not so attractive. After that we start using computer which removed all of these problems. Now a day the books, newspapers, leaflet, cash memo etc are composed using computers for printing and publications. It has saved our time and money. The production of printed materials are now more clear and attractive. Now we can do the job of typing both in Urdu and English by computer. How to type using computer Mouse and keyboard To do the job of typing by a computer first of all we need to open a word processing program. Microsoft word is a famous word processing program. After opening this program we can start typing with the help of keyboard. We can start English typing directly after opening Microsoft word. If we want to type in Urdu, we need to give a command using the keyboard. Mouse is also an important device for typing. We use mouse to select something or to give any command. Description of the Window The screen that appears just after opening Microsoft word is called Microsoft word program's window. We do the work of typing on the table with papers, pen, pencil etc. This window is something like that. We perform typing in this window. There are some elements in it which help typing. They are - Menu bar, Title bar, Toolbar, Ruler etc.
Tab: On the upper portion of the screen there are Home, Insert, View etc in a line. This line is called Tab bar. Home, Insert, View etc are the name of Tabs. There are several commands under a tab. We can do several works using these Tabs and commands. Ribbon
The small icons placed in a line below the tab bar is called Ribbon. We can select fonts alignments, size, shape of fonts etc by using the icons of this ribbon. Ruler There is a ruler in the bottom of Ribbon. We can measure the page and width of line or paragraph etc. The blank space below the ruler is used for typing. Vertical and Horizontal Scroll Bar There are scroll bar at the right side and bottom of the page or screen. The scroll bar at the right is vertical scroll bar and in the bottom is horizontal scroll bar. There is a scroll arrow in both end of scrollbars. In the middle of them there is a scroll box. We can see the end of text bringing on the screen using these scroll boxes. Page Size Before starting typing we need to fix the page size. We should fix it according to the size of paper. We can do this by page setup dialog box. We will discuss it in detail in the practical part. Urdu and English We can type both in Urdu and English in computer. We can type in English normally after opening Microsoft Word. But if we want to type in Urdu we must prepare the program with required commands. We will discuss it elaborately in practical part. Saving Text After typing something or in the middle of typing we need to save the text. Because the sudden failure of electricity or any other incident the text will be erased, if not saved in the meantime. So we should save the text in the form of file, so that, we can use it in any time for further needs. Closing the file If we need to stop typing then we need to give the Close command. To do this we need to select Close from Office button. If we close the file without saving then the computer will show an alert message 'Do you want to save the changes of this page?' Then we need to click yes button and then save it. If we want to work in that file again then we need to open that file again. We will discuss it in detail in Practical part. Editing and Formatting Text Spelling Correction Spelling correction is the indispensable task of editing. Basically spelling correction means to correct wrongly spelled words. If we make any mistake in spelling the computer will mark it by red underline. Then we need to correct the spelling of the word. If there is a dictionary program in the computer then it will suggest the correct words. Cut, Copy and Paste With the operation of cut, copy and paste command we can move and remove word, sentence or part of a sentence from one place to another. If we cut the selected part and paste into another place then the original one is moved to the new place. But if we copy and paste, then the original word will remain as it was and a new copy will be moved to the new place. It is also an important part of editing. Undo Undo command of Edit menu is very important. If we erase any text unwillingly or by mistake, we can get it back by this command. By this command we can also get back the immediate past text formatting.
Font size For editing we need to change the size of fonts. Suppose the fonts of headline of a text is bigger than the fonts of the text. We can change the size of font measuring by points. We can change a font from I point to 16 38 point. Bold, Italic and Underline According to the necessity we can make a word or selected portion of text, bold, Italic or Underline. Alignment There are four alignment icons in the ribbon. They are left alignment, right alignment, centre alignment and justify alignment. We can change the alignment according to the need. To do this we need to select the text and then click on the respective alignment icon. Column In the newspaper the articles are presented in columns. Making column is very easy. It is easy to do editing in column. It does not matter whatever the height and width of text at the time of typing. The text can be placed into columns at anytime easily. Formatting of newspapers, news letters, magazines and so on are done by this tool. Table By this tool we can present different data in different sells. Suppose there may be names, addresses, numbers etc used as the heading of respective data. We can present all of these in a table. Sometimes we need to add some other information. Then we can easily add rows or columns of the table. Header and Footer Sometimes the title of a book is used on the top of every page. It is called header. It can be of one or several lines. But usually single line is used for header. In the same way, some information, page number or forma number etc. may be used at the bottom of page. It is called footer. Foot Note In a research report or research article sometimes we need to add some note to explain the topic. It is called Foot Note. Usually we use it on the bottom of the page. Page Setup After editing and before printing we need to fix the size of the page filling in the measurement values in the page setup dialog box. It is called page setup. The line spacing, space in left, right, top or bottom and the type of the paper can be fixed up by this dialog box. We can also fix the margins of the paper by this dialogue box. Summary In the early days people used to prepare color from flowers and write on the paper using those colors. Later they discovered typing machine. After sometimes a device was developed named word possessor the word processor. The word processor had memory and several fonts. Using personal computer for typing started in the leaf of seventy. Invention of microprocessor opened a new era of hope in 1971. Before making Macintosh computer of Apple Company there was only English font for typing. But Macintosh computer removed this problem. In our country we also use Macintosh computer for typing Urdu. It was the first Urdu weekly which was published using Urdu software. Now a day’s almost every newspaper is published using computer.
We use keyboard like type writer for the work of computing. There are a number button in a keyboard which are used to give commands. On the top of the keyboard there are 12 (Fl-F12) keys which are called function keys. The work of typing for publication is called desktop publishing. The publishing of books, newspapers or correspondence depends on desktop publishing by personal computer. In previous time the job of desktop publishing was done by Macintosh computer. Now a days all the works of publishing, editing, formatting are done by personal computer. Exercise Multiple choice questions 1. In Word processing program of computer, spell-checking is called- a. proof reading b. debugging c. encoding d. editing [For the questions 2 and 3] Using the menu of MS-Word, the students are asked to create a 'Table'- 2. To prepare the 'Table', they will follow the command- i. Table —> Insert—> Table —> Enter ii. Table —> Insert—. Tools —> Enter iii. Insert—> Table —> Tools —> Enter Which one of the following is correct? a. i b. i and ii c. ii and iii d. i, ii and iii 3. 3. Which command is used to mix up together 4 cells in a table? a. Delete b. Merge c. Delete Table d. Shift + Delete 4. 4. Which key is used to increase the number of rows? a. Shift b. Tab c. Ctrl+Shift d. Ctrl+Enter Long Questions Mr. Abdus Sattar is a clerk serving in an Insurance compny. Still now he uses the type writer for writing various types of letters and other written work. One day, all of a sudden, he prepared a letter taking considerably less time and for that he made some mistakes in spelling and dropped some words. His senior officer became angry for that reason. Mr. Sattar said sorry and humbly requested his officer to purchase a computer. With the help of computer, it is easy to work fast and error-free. a. Which program is used for letter writing in computer? b. Describe one of the main advantages of write something in computer. c. Describe the process, how Abdus Sattar Saheb can do spell-checking and insert necessary words using a computer. d. Analyse the role of computer in respect of writing letters quickly and error-free.
Unit – 5 Spreadsheet Analysis (Microsoft Excel 2007) After studying this unit the students will be able to understand; Description of Spreadsheet Different types of calculations are performed using spreadsheet program. Excel is a popular spreadsheet program. Simple and complicated calculation can be done by spreadsheet program. To calculate by spreadsheet program appropriate formulas are used. Suppose, a big calculation of debit, credit, profit etc should be accomplished. For this type of complicated calculation, summation, subtraction, addition, multiplication, division, percentage etc are to be applied using formula. It needs huge time to do such calculation with pen and paper. Besides, there is a possibility of mistake. If a number of a calculation changes then the other related numbers have to be changed. But it could be done flawlessly and in minimum time by Excel. Because of arranging calculation chart by formula, if correct number is typed in place of a mistake then the whole calculation changes automatically and we get a flawless result. Market behavior analysis and future assumption is possible by spreadsheet. It could be expected the next two-three years market, analyzing past four-five years market tendency. Besides that, different types of survey result could be presented by spreadsheet program. As for an example- population growth rate, literacy growth rate and male female ratio etc is easy to understand for general people if presented by chart or graph of excel. Worksheet After opening a spreadsheet program, a screen is presented which is called worksheet. In the same way an empty document is found after opening Excel. There are innumerable cells in this empty document. These cells are arranged side by side and top-down. This empty document or sheet of calculation is the worksheet of spreadsheet program. Every rectangular part of a worksheet is called cell. The running cells from top to down is called column. Every column is marked by one English letter. For example, the columns are named as column A, column B, column C etc. The cells from left to right are called row. Every row is marked by English number 1,2,3 etc. For example, Row 1, Row 2, Row 3 etc. The cross section of columns and rows are referred to its position. Suppose, the cell situated on the cross-section of row 12 and column C is called C12, 9th cell of column E is called E9 etc. If any cell is clicked by mouse pointer, it becomes active. The
rectangle part of an active cell is bold lined. The subject matter of active cell is displayed in the upper side of screen in Formula Bar. In the practical section this acquaintance had been explained in detail. Both Urdu and English can be used in spreadsheet. There are 16,384 columns, 1048576 rows and total 171798 69184 cells in an Excel - 2007 worksheet. Use of Formula Formula is a set of instruction given in a specific method. One or two works can be done at a time by direct instruction. But more than one instruction can be provided by a formula. The mentionable feature of a formula is that it can provide conditional instruction. For example - the calculation of salary of offices, industries and big business companies, service holders can be done easily by formula set into appropriate cells. Calculation will be done at a time and automatically on typing the figure of salary in the respective cell. Suppose that, there is a relation between house rent and basic salary. If the basic salary is Rs.10,000 then house rent is 50% of basic salary.
When basic salary is less than Rs. 10,000 then house rent is 75 % of basic salary. Conditional formula has to use for these types of conditional house rent calculation. After that if the basic salary is inserted in the respective column then automatically house rent will be calculated in the relative column. The figure of House rent could be high or low if it is mistaken to type the main salary. But the advantage of using formula is that if the basic salary is corrected then the house rent will be corrected automatically. Testing Worksheet A worksheet should be tested after it is prepared. Suppose, a worksheet has been prepared for keeping account of a person's monthly profit. The fields of income and expenditure are included there. Net-profit can be calculated by subtracting total expenditure from total income. For this, it is needed to use a formula for total income, total expenditure and subtracting total expenditure from total income. To test, if the formula is set perfectly, we have to use small amount, so that we can understand the result on display. If a small number gives an accurate result then a big number will also give an accurate result. Editing Text Excel worksheet text can be edited like the Microsoft word. After selecting text, if we select Cell command from Format menu then a mixed dialogue box will appear. There are number, alignment, font, border, pattern and protection tab in this dialogue box. Necessary task could be performed clicking on the relevant tab. Changing font size, coloring text etc can be done using this dialogue box. One or more column can be coloured for giving emphasize or to make attraction. Row also can be coloured. More types of editing are explained in practical section. Chart/ Graph Different types of survey works can be represented in the form of chart or graph. One can get the primary idea easily from a chart or graph. Chart or graph is created by used number, month/year etc in worksheet. There are different types of chart or graph. Such as column, bar, line, XY (Scatter), area, donut, radar, surface and bubble. The form of a chart or graph is different as its
name. But, the data of a chart remains same. Among these, columns, line and pi chart are widely used. Spreadsheet Analysis If it is clicked on chart then it is selected. Chart menu will present a dialogue box with different types of charts. There are different types of chart model and name in dialogue box. When a chart is selected from the list it will display different form of that chart at right side. If we click OK bottom the selected chart will appear on screen. After making a chart we can change it to any other form by using one or two commands in any time, if it is needed. There are various texts in every side of the chart. The legend is set in right side. Legend is a symbolic sample represents different columns, lines, other sign which are presented in graph and chart. When any text or legend is selected by clicking on it by mouse pointer then the text box is selected. Font and letter size can be changed from pull-down menu of toolbar when it is selected. Text could be arranged as per need as bold, italic, underline etc. using the tools on ribbon. Saving Worksheet Like other programs, a worksheet should be saved by selecting save command from file menu. The location of saving can be set in the save as dialogue box by selecting folder and typing the name of the worksheet. Summary
The program for calculation in computer is called spreadsheet program. We can do easy to hard calculation by spreadsheet program. In spreadsheet program we have to correct only the mistaken number then all other corresponding calculations are corrected automatically. After getting any result in spreadsheet program if we change one or more number then the related result changes automatically with new calculation. If we calculate this calculation with calculator it will take much time. Besides this, we have to delete old numbers to write new numbers in calculation on paper. But in spreadsheet program only changed members typing are enough. All other calculation will be done automatically. Characteristics of spreadsheet are very important for big and mixed calculation. By spreadsheet program we can analyse market and future trend. Analyzing past four-five years market inclination we can draw the trend of two or three year's future market. Another important characteristic of spreadsheet program is graph or chart. If we present a survey report in graph or chart it becomes clearer to descriptive writing. After opening the program a blank sheet with thousand of cells appears. This sheet is called worksheet. These cells are arranged in row and column. Again every cell has address for its own position. Sometimes some cells are selected, together for any specific work. Then the selected area is called range. To calculate by spreadsheet program different types of formulas and functions are used. For example -mathematical formula, logical formula etc. Microsoft excel is a very popular and widely used spreadsheet program in windows and Macintosh operating system. Microsoft company developed Excel spreadsheet program in 1985 for Macintosh computer and in 1987 for IBM PC compatible computers. Before that Lotus -1-2-3 was widely used spreadsheet program for DOS operating system of IBM personal computer. Exercise Multiple choice questions Look at the spreadsheet and answer questions 1-4 : A B C D EF 1. Name Urdu English Computer Economics Total 2. Sabita Rani 85 45 84 65 3. Farzana Alder 60 56 S' 75 4. Shamim Ahmed 85 69 7' 45 5. Probal Rama 74 57 80 90 6. 1. Which formula is correct to determine the sum of four subjects from the worksheet? a. = Sum (B2 : B5) b. = Sum (B2 : E2) c. = Sum (B2 + B5) d. = Sum (B2 + E5) 2. Using the worksheet, it is possible to perform - i. word processing ii. calculation iii. the task for graph -chart Which one of the following is correct? a. i b. i and ii c. ii and iii d. i, ii and iii
3. Using the worksheet, which one is to be done first to create a graph? b. To run the wizard c. To select the criteria of the graph d. To select the data-range e. To decide for the 'Title' of the graph 4. Which one of the following can be used to create a graph or chart easily? a. Table Menu b. Chart Wizard c. Chart Title d. Chart Menu Long Questions Serial Name Basic Medical Total Salary with Numb Salary 1. er Amina 7,000.00 Allowance Allowance 2. Prema 500.00 6,800.00 500.00 3. Shadat 8,000.00 500.00 4. Arpana 5,100.00 500.00 5. Nasrin 7,200.00 500.00 6. Sajal 9,500.00 500.00 This worksheet is saved by the name 'Salary'. Here the house rent of the officers and employees is 40% of the basic salary. a. What do you mean by worksheet? b. Describe one of main characteristics of spreadsheet program. c. Describe how to determine the total salary with allowance inserting a column named by 'House Rent' in between Basic Salary and Medical Allowance columns. d. Analyse that total salary with allowances can be ascertained correctly by using spreadsheet program.
Unit - 6 Database (Microsoft Access 2007) After studying this unit the students will be able to understand; Database: The information or data can be preserved in a computer as file. The preserved file is called database. A database is mainly formed with fields. There can be names and types of field. Heading helps to understand the types of information or data it contains. The headings are known as Field. A row is formed with the cells of columns run from left to right side-by side. Each row is called Record. The following database can be observed. Serial Name Age Female/ Male 1 Abdul Khaleq 22 M 2 Hamida Khatun 35 F 3 Abdul Malck 40 M Here Serial, Name, Age, Female/Male are headings of columns. These headings are the fields of database. The information of row one - Abdul Khaleq, 22, M go side by side which is called record. In the above form there are 4 (four) fields and 3 (three) records. All the records together are called database. Database is described as the storage of information. Huge amount of information can be preserved or stored as database. The preserved information can any time be edited, new information can be added and unnecessary information can be dropped. Any information from the preserved database can any time be known, produce as created report and provided in edited form. For example, the various information of people of any area can be preserved in a database. From this database the number of male, female, the number of youth below the 18 years can be found any time and in a few minutes. Microsoft Access
Microsoft Access of Microsoft Corporation is one of the popular programs for database. Access is a window based powerful relational database management system. Huge amount of data or information can be preserved and processed by using Access. Different Objects of Access Database The elements used in Access program are called objects, for example, table, record, field, forms, report etc. Table The main object of Access database is Table. Table is the soul of database. Information received from different sources is primarily included in database. The data included in a table can be corrected any time. New information can be added to the same table. Information are provided or served in different section from the preserved information in the table, whenever necessary. Separate tables are prepared for separate subject. To work with many subjects, more than one table is prepared and the relationship between the tables is also established. This system is called relational database. If database is prepared including various information about the people of an area it will be a big database. Database can also be created with the students, teachers and other workers of an educational institution easily. Field and Record The small unit of information of any database is a field. A record is created with Abdul Khalek, 22 and M field in the above table. In a sentence, record is the information of many fields placed together. For as many rows so many records will be created. The small unit of record is field. The Serial, Name, Age, Male and Female of the preceding table is an individual heading of field. Data All kinds of information included is a table are regarded as data. Name of a person is a data, the number is also a data. Therefore, data can be both letter based and number based. The other data beside these are: Text data: Maximum 255 characters can be used in Text data type. Dot, comma, colon, semicolon can be used in text field. No mathematical calculation, such as, addition, subtraction, multiplication, division etc can be done with the help of the text data field type. Number Data Mathematical calculation, such as, addition, subtraction and multiplication, division are done by number data type. Currency Data Currency data type is used for money related data. Mathematical function can also be done by the number used in this field. Besides, number data type can be used for calculation of money is possible. Date /Time Data Date or time data type is used for the data related to date and time. Both time and date can be used in Date /Time field. Memo Data Memo data type is used to write any kind of comment about any data. if necessary, excessive memo data type is used to preserve information. Auto Number Data
Sequential /serial number is used in each record. If Auto Number Data type is used it cannot be changed later. Yes/No There are some data which in the field of entry Yes/No can be used. These data are called logical data. At the time of logical data entry Y or N express Yes and No and F indicates No. For example, Yes/No data type is used to indicate if the fees of a student are paid or not. Field Property For starting the work of database and at the stage of creating file some subjects are determined for each field. These subjects are regarded as Fields property. The data of those fields are used according to the properly determined field. The field size is one of the important property of text field property. Field Size: The capacity of text field is to be determined by field size property. Every field has its own capacity as default. The user can change default according to his need. For example, the capacity of size property of text field is fifty (50) characters. The user can use two hundred and fifty five 255 characters if he feels necessary. When the capacity of field size property is fixed to fifteen (15), the character, no letter after fifteen (15) will not be visible. Format Format property is used to select how the information of a field will be displayed. To select data and time select General from drop-down number of format and then date/time will appear like - 1/7/2017. If Long Date then the date /time will be displayed as July 1, 2017. Medium Date will display 1st July 2017. In the same way, the necessary property of other field is fixed. So, the default value can be kept unchanged at the primary stage of learning. Data Table Sorting The records of information table can be arranged in both ascending and descending order. In ascending order numbers are arranged serially from lower to higher order and in descending order numbers are arranged from higher to the lower order serially. Serial number, age, any field of number, day -date etc are sorted based on first character. Data Query Data Query is done by several methods. For example, from the database of the people of an area, the information of the people of a village can be found individually. From the whole database, only the information of women, the information of people of particular age can be viewed. Besides, information query can be done by other conditions also. Summary The function of database is one of the most important task of computer. The function of database mainly means the work of data management. Data base is used to arrange information in different ways. Once complex programmings were necessary to create database. Now a days, it has become very easy. Microsoft Access is one of the most popular and powerful database software. By using Microsoft Access huge amount of information can be handled. Preserved information can be used at any time when necessary.
The preserved information can be presented in forms of form, report, table etc. From the vast amount of preserved information in database particular information query can be arranged in a few minutes. In query process the information of database is searched. Exercise Multiple choice questions [Read the following paragraph and answer questions 1 and 2.] A software named 'Student Information System' will have to be created for your school, the sample for the software is as follows: ID Name Class Address City Grade 001 Tahir VIII A Lahore A 021 Jamal VIII B Multan A+ 033 Islam VIII C Gujarat A+ 121 Nadeem VIII D Faisalabad A+ 002 Saeed VIII E Rawalpindi A+ Here, ID is considered as the primary key. 1. Here, Address is- a. Byte b. Field c. Record d. Information 2. To represent separately, the students of class eight who have achieved A+,(-)will have to be used- a. Query b. Select c. Table d. Memo 3. Suppose, there is a database file for all students in your school. To separate the names of all students from the database you will- i. create a new Table ii. make query iii. make a report Which one of the following is correct'? a. I b. ii c. ii and iii d. i, ii and iii 4. What is the primary unit of Information? a. Field b. Record c. Data d. Cell Long Questions Let us consider, as per the decision of the Government, Lahore City Corporation has set up Computer Based offices in each ward for the birth registration and ward commissioners are instructed to send the information everyday for birth registration. For birth registration, it is urgently required to input some information- Date of birth, Male/ Female, Father's name, Mother's name, Religion and Birth place. a. What is database? b. What type of database is suitable to implement the above mentioned program? c. Represent a sample database of 5 children taking the fields from the above information. d. Analyse the advantages received by the City Corporation from the aforesaid database.
Search