Saturday, December 30, 2006

Introduction
In the early days of programming, it was usually the scientific elite doing the programming and they were usually trained above and beyond the average American to do their programming work. It was not until 1964 at Dartsmouth college that the Beginner's All-purpose Symbolic Instruction Code would be introduced -- more commonly known as BASIC. Using common English to perform processor tasks, BASIC became quickly popular, although it was disliked by programmers of more "low-level" languages such as assembly and FORTRAN. In 1985 Microsoft released their own version of BASIC called QBasic with their MS-DOS 5.0 operating system. Since then, nearly every PC user owns their own copy of QBasic, making it a widely known language.
QBasic is a very simple language to pick up, and yet it can accomplish a great deal. Granted you will probably never write Doom or Word Perfect with QBasic, but it has it's strong points. One of them is to introduce people to programming without having to worry about the internal workings of the computer. It's simple to create games, business applications, simple databases, and graphics. The best aspect of the language is it's close resemblance to English.
This small tutorial introduces the simple concepts of programming to get you started, so if you already know another language or are already familiar with programming, you may want to skim through the first couple sections. Good luck!

VARIABLES
A variable, simply defined, is a name which can contain a value. Programming involves giving values to these names and presenting them in some form to the user. A variable has a type which is defined by the kind of value it holds. If the variable holds a number, it may be of integer, floating decimal, long integer, or imaginary. If the variable holds symbols or text, it may be a character variable or a string variable. These are terms you will become accustomed to as you continue programming.
Here are some examples of values a variable might contain:
STRING "hello, this is a string"INTEGER 5LONG 92883SINGLE 39.2932DOUBLE 983288.18
The first is a string. Strings contain text. The last four are number types. But the computer does not know what kind of value you are trying to give a variable unless you tell it! There are two methods of telling the computer what kind of variable you are using:
Explicitly declare the variable AS a type. This is done by using the DIM statement. Say you wanted to make a variable called number which would contain an integer (whole number, no digits after the decimal point). You would do it like this:
DIM number AS INTEGER
Then you would use that variable as an integer. The word DIM actually originates from the word Dimension, but you won't see why until we discuss arrays.
Put a symbol after the variable name which is defined as representing that type. QBasic has a set of symbols which represent each variable type:
$ String% Integer& Long! Single# Double
Appending one of these symbols to the name of a variable when you use it in the program tells the computer that you are using it as that type.
This is actually a difficult concept to grasp for newcomers to programming. The most common error in QBasic is the infamous Type Mismatch which you will see a lot. This means that you are trying to put a value into a variable of the wrong type. You might be trying to put the letters "hi there" into an integer variable. If you don't define the type of the variable, then QBasic assumes it is of the Single type, which can often yield unexpected results. I personally prefer to use the type symbols after variable names, but come explicitly declare them usually at the head of their programs.

Sunday, December 17, 2006

Full Form

2D – Two Dimension
3D – Three Dimension
4GL – Fourth Generation Language
ABC – Atanasoff Berry Computer
AC – Alternating Current
AI – Artificial Intelligence
ALGOL – Algorithmic Language
ALR – Advance Logic Research
ALU – Arithmetic and Logic Unit
ANSI – American National Standard Institute
ASCII – American Standard Code for Information Interchange
AT – Advanced Technology
AT & T – American Telephone and Telegraph System
ATM – Automatic Teller Machine
BASIC – Beginner's All purpose Symbolic Instruction Code
BCPL – Beginners Cambridge Programming Language
BCR – Bar Code Reader
BIOS – Basic Input Output System
Bits – Binary Digit
BMP – Bit Mapped Graphics Image
BPI – Bytes per Inch
CAD – Computer Aided Design
CAL – Computer Assisted Learning
CAM – Computer Aided Manufacturing
CBI – Computer Based Instruction
CBIS – Computer Based Information System
CBT – Computer Based Training
CC – Computer Consultancy
CD – Compact Disk
CDROM – Compact Disk Read Only Memory
CDRW – Compact Disk Read and Write
CESIL – Computer Education in Schools Instruction Language
CGA – Color Graphic Adapter
CGI – Common Gateway Interface
CISC – Complex Instruction Set Computer
CMOS – Complementary Metal Oxide Semiconductor
COBOL – Common Business Oriented Language
CODASYL – Conference of Data System Languages
COM – Computer Output to Microfilm
COMPUTER – Commonly Operated Machine Particularly Used for Trade Education & Research CP/M – Control Program for Microcomputers
CPU – Central Processing Unit
CRT – Cathode Ray Tube
CU – Control Unit
CUI – Character User Interface
DBMS – Database Management System
DC – Direct Current
DES – Digital Equipment Corporation
DHTML – Dynamic Hyper Text Markup Language
DOM – Document Object Model
DRAM – Dynamic Random Access Memory
DSDD – Double Sided Double Density
DSHD – Double Sided High Density
DSI – Data System International
DSS – Decision Support System
DTP – Desk Top Publishing
DVD – Digital Versatile Disk
EBCDIC – Extended Binary Coded Decimal Interchange Code
EDO RAM – Extended Data Out Random Access Memory
EDVAC – Electronic Discrete Variable Automatic Computer
EEPROM – Electrically Erasable Programmable Read Only Memory
EGA – Enhanced Graphics Adapter
EICAS – Engine Indicator and Crew Alert System
EISA – Extended Industry Standard Architecture
EMS – Expanded Memory
ENIAC – Electronic Numerical Integrator and Calculator
EPROM – Erasable Programmable Read Only Memory
FAT – File Allocation Table
Fax – Facsimile
FDD – Floppy Disk Drive
FMC – Flight Management Computer
FORTRAN – Formula Translation
FPM DRAM – Fast Page Mode Dynamic Random Access Memory
FTP – File Transfer Protocol
GaAs – Gallium Arsenide
Gb – Giga bytes
GIGO – Garbage in Garbage Out
GUI – Graphic User Interface
HDD – Hard Disk Drive
HTML – Hyper Text Markup Language
I/O – Input / Output
IBM – International Business Machine
IC – Integrated Circuit
ICL – International Computers Limited
IMG – Image Element
IRTB – Industrial Real Time Basic
ISA – Industry Standard Architecture
IT – Information Technology
K (or Kb) – Kilobytes
LAN – Local Area Network
LCD – Liquid Crystal Display
LCM – Least Common Multiple
LED – Light Emitting Diode
LISP – List Processing
LSI – Large Scale Integration
MAN – Metropolitan Aria Network
Mb – Mega bytes
MCGA – Multi Color Graphics Adapter
MD2D – Mini Disk Double Sided Double Density
MD2HD – Mini Disk Double Sided High Density
MDA – Monochrome Display Adapter
MF2D – Microfloppy Disk Double Sided Double Density
MF2HD – Microfloppy Disk Double Sided High Density
MHz – Mega Hertz
MICR – Magnetic Ink Character Reader
MIPS – Management Information Processing System
MIPS – Millions of Instruction per Second
MIS – Management Information System
MODEM – Modulator and Demodulator
MOS – Metal Oxide Semiconductor
MSI – Medium Scale Integration
NCC – National Computer Center
NEC – Nippon Electronics Company
OAS – Office Automation System
OCR – Optical Character Reader
OMR – Optical Mark Reader
OS – Operating System
OSS – Operating System Software
PC – Personal Computer
PC – Personal Computer
PCB – Printed Circuit Board
PCI – Peripheral Component Interconnect
PILOT – Programming Inquiring Learning or Teaching
PL/1 – Programming Language – 1
POP – Post Office Protocol
POST – Power On Self Test
PROLOG – Programming Logic
PROM – Programmable Read Only Memory
PS/2 – Personal System – 2
PSTN – Public Switched Telephone Network
QBE – Query by Example
QEL – Query Language
QIC – Quarter Inch Cartridge
RAM – Random Access Memory
RISC – Reduced Instruction Set Computer
RMM – Read Mostly Memory
RPG – Report Program Logic
RPM – Revolution per Minute
RW – Read and Write
SCSI – Small Computer System Interface
SDRAM – Synchronous Dynamic Random Access Memory
SGML – Standard Generalized Markup Language
SIMM – Single Inline Memory Module
SMPS – Switch Mode Power Supply
SNOBOL – String Oriented Symbolic Language
SQL – Structure Query Language
SRAM – Static Random Access Memory
SVGA – Super Video Graphics Array
Tb – Terra bytes
TCP/IP – Transmission Control Protocol / Interface Program
TPS – Transaction Processing System
TV – Television
UMB – Upper Memory Block
UNIVAC – Universal Automatic Computer
UPS – Uninterrupted Power Supply
UPS – Uninterruptible Power Supply
URL – Universal Resource Locator
USB – Universal Serial Bus
VDT – Visual Terminal Unit
VDU – Visual Display Unit
VGA – Video Graphics Array
VLSI – Very Large Scale Integration
WAN – Wide Area Network
WORM – Write Once Read Many
WWW – World Wide Web
XGA – Extended Graphics Array
XML – Extensible Markup Language
XMS – Extended Memory
XMS – Extended Memory Specification
XNS – Xerox Network System
XT – Extended Technology

History of Networking

The History of Networks is a long and complex story. It is filled with many small events that build upon others that contribute to the whole. This history gives one a general guide to this quickly changing field. Even as this was being written some new innovations in networks have been born.
Beginning in the late 1960’s, people working with computers started looking into ways to link them together. The idea of a network of computers was intriguing both as a topic of pure research and for the design and provision of services. This initial research concentrated on networks that dealt in packet switching. That initial research was funded by a United States government agency called the Advanced Research Projects Agency (ARPA.) The Department of Defense (DOD) wanted to create a computer network that would continue to function in the event of a disaster or attack, even one on a nuclear scale. If part of this network were to be damaged or destroyed, as an ICBM would be sure to do, the rest of the system still had to function. That system was called ARPAnet. It linked U.S. scientific and academic researchers together and became the first successful computer network.
The initial motivation for the ARPAnet and networks in general, was resource sharing. For this to occur the computers must be able to communicate to each other. In 1965 an experiment was conducted to explore how to do this. A TX-2 computer in Massachusetts was connected to a Q-32 in California using a low speed dial-up telephone line. This was the first wide-area network (WAN) ever built. This network proved that time-shared computers could work well together, running programs and retrieving data necessary on a remote machine. However, the method of using a circuit switched telephone system was inadequate for the task, a new method had to be developed.
The 1965 experiment confirmed the need for a system involving packet switching. This was seen as a major advancement in networks. By the end of 1969, four host computers were connected. These hosts at the Stanford Research Institute UCLA, UC Santa Barbara and the University of Utah together created the initial ARPAnet. The success of ARPAnet, attributed to the uniform allocation of three major services to all connected computers: remote login, file transfer and electronic mail. With success comes growth, and by 1971 the ARPAnet connected 23 hosts at government research centers and universities across the intercontinental United States.
To this point, computers network were a mystery to the general public, as well as academics in countries other than the United States. In October 1972, this changed. A large- scale demonstration of the ARPAnet was held at the International Computers Communication Conference (ICCC). This demonstration organized by Bob Kahn was a complete success. Later in 1972,
electronic mail introduced. This was the initial “hot” application of the ARPAnet.
1972 also saw a change in the focus of ARPA. The agency was fully incorporated into the DOD, and the mandate was redirected. ARPA became Defense Advanced Research Projects Agency (DARPA) and ARPAnet became DARPAnet. This new agency and the network now under its control had an objective geared more towards military research.
By 1973, it was determined that the protocols utilized by the lower layers of DARPAnet were now functionally inadequate. Research then began into finding a protocol that was workable for a network of the size of DARPAnet or larger. The main features of TCP/IP, the common language of computers connected to networks, and gateway architecture were activated by mid-1974. Several versions of TCP/IP had been developed for DARPAnet by the early 1980’s. These versions of TCP/IP were all implemented and critically analyzed so that improvements could be made. Each version was also designed to support an increasingly wider range of sub network technologies, whether they were applications or other protocols.
After the stabilization of protocols within the academic community DARPAnet was connected to several other networks in the United States: CSnet; Britnet; and USEnet/uucp. Soon after this, the collection of networks was given its own name in 1982. For the first time the term ‘Internet’ was used. From 1982 to 1987 many more-smaller networks joined the Internet.
The 1990’s saw a vastly accelerated amount of change in the Internet. ARPAnet, a victim of its own success is decommissioned in 1990. All that remained was the vast network of networks called the Internet, with over 300,000 hosts. With this, the
National Science Foundation took over the management of the Internet. NSFnet was soon after made the backbone of the Internet. In 1991 the NSF, facing pressure from corporations to lift its ban on commercial traffic, opened the Internet to commercial use. The way was cleared for electronic commerce, and the world’s economy was irrevocably changed forever. With commercial traffic come non-academic users. So, in 1993, Mossaic, the first graphics-based Web browser, becomes available. After this, many follow making the web accessible to the general public. The end of the 1990’s saw the number of computers connected to the Internet surpass 4 billion. The current IP version, IPv4 was inadequate, so early 2000 saw the introduction of IPv6. This new protocol was designed to bring the Internet into the 21st century with improved security, multimedia applications support and the capacity for over 3.4x1038 computers to be online.

NETWORK

What a Network is?
A
Network is a group of two or more computers connected together. This connection is done through a physical infrastructure using a wired or wireless system. These computers are able to communicate and exchange information because they agree to use software that observes the same set of rules, or protocols. Different types of computers, with different operating systems, can use a Network. They are connected so that they communicate with each other and share information, but only as long as they follow the some general rules, called Network protocols. Networks can interconnect with other Networks and contain many levels of sub Networks. The most common general configurations (or topologies) of Networks include the: bus; star; and ring topologies.
Networks can also be characterized in terms of their size. The size is a measurement of the spatial distance that the network covers. Local area Networks (
LANs), metropolitan area Networks (MANs), and wide area Networks (WANs) are the three main divisions used by people in the field. A given Network can also be characterized by many factors:

  • The type of data transmission technology used on it (for example, a TCP/IP Network)
  • Whether it carries voice, data, or both kinds of signals
  • By who can use the Network (public or private);
  • By the usual nature of its connections (dial-up or switched, dedicated or nonswitched, or virtual connections);
  • By the types of physical links (for example, optical fiber, coaxial cable, and copper wire).

Saturday, December 16, 2006

Output ????

DECLARE SUB Result ( )
CALL Result
END
SUB Result ( )
n = 5
c = 1
WHILE c < = 5 PRINT n n = n * 10 + 5 c = c + 1 WEND END SUB END


OUTPUT
5 55 555 5555 55555

Question & Answer

a) What does modular programming mean?
Ans: Modular programming means the breaking down the big program into small programs or modules.
b) Give the difference between local and global variables.
Ans: Local Variable: Local variable is a variable which is defined within function block or area i.e. no other function can use that variable.
Global Variable: A variable declared outside a function is called global variable and is accessible to all the functions that are called after its declaration.
c) Give the function of CLOSE and KILL statements.
Ans: Functions of CLOSE and KILL statements:
CLOSE: This statement is used to close after writing, reading or appending. This statement is written before ending the program.
KILL: This statement is used to erase the innocent file of innocent disk.

Read the following program and answer the following questions.
DECLARE SUB String(X$)
X$ = "COMPUTER"
END
SUB String(X$)
L = LEN(X$)
FOR i = L to 1 STEP - 2
PRINT MID$(X$, i, 1);
NEXT i
END SUB
END

a) What statement should be added in main module to execute the program?
Ans: CALL String(X$)
b) What will be the output of the program?
Ans: R T P O
c) What will the value of L if X$ = "NEPAL"
Ans: 5
d) List out numeric and string variables used in the program.
Ans: Numeric Variable: L, i
String Variable: X$

Friday, December 15, 2006

FILE MANAGEMENT

Introduction:
We have so far discussed programs where data is supplied either through READ...DATA statements or through INPUT statements. But it is difficult to handle large volume of data with the help of these statements. Moreover, data stored in one program cannot be shared by other programs. The above limitations can be overcome by placing the data into a separate storage area called a data file.
A date file forms an essential framework of a data processing system. It is a collection of data organised in a specific format and for a specific purpose, which is kept somewhere in external memory. A file can be described as a collection of records where a record consists of number of data values, which are either produced by a computer as per the instructions of a program or given to the computer as a data. A typical data processing system many consist of many files. Many records in a file contain detailed information about some aspect of the system. For example, a "pay file" may contain one record for each employee containing all the particulars such as Employee Code, Name, Address, Basic pay, HRA, DA, CCA, Designation, Sex, etc. Each partition is a data item and is referred to as a field. A number of BASIC Programs can use this file as input.
File handling methods differ widely from system to system. In this lesson, we will discuss the methods that are currently used in most of the IBM compatible systems.

OBJECTIVES
On completion of this lesson, you should be able to:
· understand various types of files
· know how to handle sequential files
· know how to handle random access files
· discuss various examples/ programs relating to these two type of files.

TYPES OF FILES
Depending on the way in which the data is stored and accessed, files are categorised as:
· Sequential access files
· Direct (Random) access files

Sequential Access Files
These files may be created on a magnetic tape or disk. Data from these files is read sequentially, item after item, starting at the beginning. Though sequential access file is easy to handle, yet it has a serious disadvantage. In the sequential file we cannot change the existing entry or insert a new entry. To do this, we should copy the entire content to another file making the changes on the way and then copy the correct data back in to the original file. Another disadvantage is that we cannot simply locate or go back to read a particular data item.
Consider an inventory file shown in Table 1.1
Part name Part number Price Quantity
AAAA 101 8.00 100
BBBB 102 10.00 200
CCCC 103 12.00 300
Table 1.1 Inventory file
Details of each part are stored in one record. When we complete all the parts, the data file would look like a long column of values as shown below:
AAAA 101 8.00 100
BBBB 102 10.00 200
CCCC 103 12.00 300
Programs are written to read these data values one after another.
Random Access Files
Random access files are created on disks to allow us to read or write from the files in random order. Random access files allow more flexible access than the sequential files. You can read or write any record directly in a random file without searching through all the records that precede it. Thus, reading and writing of data is faster.

HANDLING OF SEQUENTIAL FILES
Using data files would require the incorporation of statements in your program to perform the following functions:
· Giving a name to the file
· Opening the file
· Writing to or reading from the file
· Closing the file

Naming a file
A file is identified by its file specifications. It is of the form:
[Device name: File name]
The device name tells the system which device to look for the file and the file name tells which file to look for on that device. The device name should be followed by a colon as indicated. Examples are:
A: MEAN
B: STUDENT. MKS
The device names A and B indicate the disk drive one and two respectively
File names can have a maximum of eight characters. However, the files stored on disks may have a file name extension in the following form.
[NAME.EXT]
The extension consists of a period and followed by three letters. When you use longer file name, one of the following conditions may occur.

File Name
1. Extension is longer than three characters.
2. Name is longer than eight characters.
3. Name is longer than eight characters and extension is included.
Result
1. Extra characters are truncated.
2. A period is inserted after the eighth character and extra characters (up to three) are used as the extension.
3. Gives an error.
For example,
SURENDERKUMAR becomes SURENDER.KUM.
PROGRAM.PENSION becomes PROGRAM.PEN.
PAYROLLCALUCTION.BAS gives an error.

Opening a file
It is necessary to establish a line of communication between a program and a file that is to be used before data can be read from or written to that file. This is achieved by using the OPEN command as shown below:
OPEN ["Mode", #file number, "file name"]
Mode is a string constant and takes one of the following three forms
· O for sequential output file
· I for sequential input file
· R for random input/output file
It should be noted that the mode is enclosed in quotation marks.
File number is an integer number and can be any number between 1 and 15. It is a unique number associated with the actual physical file. A file number may be a number, variable, or expression.
File name specifies the particular file to be used. This should conform to the specifications of the file when it was created. File names must be enclosed in quotations.
Examples of opening sequential files for input and output operations are:
10 OPEN "I" # 1, " PANKAJ.DTA"
20 OPEN "O", # 3, "TEMP"
These can also be written as
10 OPEN" PANKAJ.DTA" FOR INPUT AS# 1
20 OPEN" TEMP" FOR OUTPUT AS #3
If a file opened for input operation does not exist, a "FILE NOT FOUND" error will be shown on the screen. If a file, which does not exist, is opened, in that case file will be created. It is important to note that opening a file for output destroys the existing data in that file.
28.4.3 Closing a File
A previously opened file can be closed using the CLOSE statement as follows
CLOSE [# file number, #file number, ......]
The file number is the number used in the OPEN statement. For example, the statement.
100 CLOSE #1, # 3
causes the files with file numbers 1 and 3 to be closed. The CLOSE statement is used when you have finished processing data from a file.
A CLOSE statement with no file numbers specified causes all files that have been opened to be closed.

You should also note that execution of END and RUN statements also causes all open sequential files to be automatically closed. However, STOP does not close any files.

Writing Data to a File
We may write data to a sequential file using either of the following two statements.
PRINT [# file number, list of variables]

WRITE [ #file number, list of variables ]
File number refers to the file designator used when the file was opened for output. List of variables specifies the data that is to be written to the file.

The difference between PRINT # and WRITE # Statements is that WRITE # inserts commas between the data items and quotation marks for strings while PRINT # causes data to be written without any delimiters (commas, etc.). For example consider the statement
40 PRINT #1 N $, AMT
In case N $ = " PANKAJ" and AMT = 2000, the
statement would write the following image to the file 1:
PANKAJ 2000

The statement
40 WRITE # 1, N $, AMT
would write the following image to the file 1:
"PANKAJ", 2000
The delimiters are useful when we try to read the data with an INPUT # statement.
Let us take an example for proper understanding the use of "WRITE" and "PRINT" statement.
Example 1
Program
10 REM *** PROGRAM INVENTI ***
20 REM -- PNM$ PART NAME
30 REM -- PN PART NUMBER
40 REM -- P PRICE
50 REM -- QTY QUANTITY
60 OPEN "O", # 1, "INVENT. DTA"
70 FOR I =1 TO 3
80 INPUT "NAME" ; PNM$
90 INPUT "NUMBER" PN
100 INPUT "PRICE" P
110 INPUT "QUANTITY" ; QTY
120 WRITE # 1, PNM$, PN, P, QTY
130 PRINT
140 NEXT I
150 CLOSE #1
160 END

Output
NAME? AAAA
NUMBER? 101
PRICE? 8
QUANTITY? 100

NAME? BBBB
NUMBER? 102
PRICE? 10
QUANTITY? 200

NAME? CCCC
NUMBER? 103
PRICE? 12
QUANTITY? 300

Reading Data from a File
Data can be read from a sequential file using the INPUT # statement. It takes the form
INPUT [ # file number, list of variables ]
The following INPUT # statement can be used to read data from the file INVENT. DTA:
200 INPUT #1, PNM$, PN, P, QTY

The type of data in the file must match the type specified in the list. Unlike INPUT, no question mark is displayed with INPUT #
The following example will illustrate clearly the use of INPUT # statement.

Example 2
Write a program to read inventory data stored in the file INVENT. DTA inventory and print the table with the value of each product.

Program
10 REM ** PROGRAM INVENT 2 **
20 OPEN I",#1, "INVENT. DTA"
25 PRINT "PART", "PART", " PRICE", "QUANTITY", " VALUE "
30 PRINT "NAME","NUMBER"
40 PRINT
50 INPUT #1 PNM$, PN, P, QTY
60 LET V= P* QTY
70 PRINT PNM$, PN, P, QTY, V
80 GOTO 50
90 CLOSE
100 END

Output
PART PART PRICE QUANTITY VALUE
NAME NUMBER
AAAA 101 8 100 800
BBBB 102 10 200 2000
CCCC 103 12 300 3600
Input past end in 50

The program in Example 2 reads sequentially, every item in the file. When all the data have been read, line 50 causes an "Input past end" error. This can be avoided by using the EOF function. This function tests for end of file and the control is directed appropriately. The end of the file is indicated by a special character in the file.

The program INVENT2 is modified as follows:

10 REM ** PROGRAM INVENT 2**
20 OPEN "I", #1 "INVENT. DTA"
25 PRINT "PART", "PART","PRICE, "QUANTITY" "VALUE"
30 PRINT "NAME", "NUMBER"
40 PRINT
50 IF EOF (1) THEN 100
60 INPUT #1, PNM$, PN, P, QTY
70 LET V = P*QTY
80 PRINT PNM$, PN, P, QTY, V
90 GOTO 50
100 CLOSE
110 END

Reading lines from a File
The LINE INPUT # statement may be used to read an entire line, ignoring delimiters, from a sequential file and assign to a string variable. It is of the form
LINE INPUT [ #file number, string variable ]

File number is the number under which the file was opened and string variable is used to store a line of string constant.

LINE INPUT # reads all characters in the sequential file up to a carriage return which was inserted by the PRINT # statement. The next LINE INPUT # reads all characters up to the next carriage return. Example 3 illustrates the use of LINE INPUT #statement.

Example 3
Write a program to input employee addresses from the keyboard, store them in a file named ADDRESS, and read back to produce a list.


Program
10 REM ** PROGRAM EMPLOYEE **
20 REM ** INPUT EMPLOYEE ADDRESS THROUGH KEYBOARD **
30 OPEN "O ", #1 "ADDRESS"
40 FOR I = 1TO 3
50 LINE INPUT "TYPE IN ADDRESS" ADDR$
60 PRINT # 1 ADDR$
70 NEXT I
80 CLOSE 1
85 PRINT
90 OPEN : "I" # 1, "ADDRRESS"
100 FOR I= 1 TO 3
110 LINE INPUT # 1, ADDR$
120 PRINT ADDR$
130 NEXT I
140 CLOSE 1
150 END

Output
TYPE IN ADDRESSES? PANKAJ KUMAR GOEL, PITAMPURA, DELHI -34
TYPE IN ADDRESSES? RAJESH KUMAR, AUDIT OFFICE, GWALIOR
TYPE IN ADDRESSES? DR. SANJU, MEDICAL COLLEGE, JODHPUR
PANKAJ KUMAR GOEL, PITAMPURA, DELHI-34
RAJESH KUMAR, AUDIT OFFICE, GWALIOR
DR. SANJU, MEDICAL COLLEGE, JODHPUR

Adding Data to a Sequential File
To add any data to a sequential file that is already residing on a disk, you cannot just open the file and write data to it. You must note that when a sequential file is opened for output, its current contents are lost. In such cases, you should open the file with APPEND. For example, the statements
10 FILE = " A: TEMP"
20 OPEN FILE FOR APPEND AS #1

will open the file named TEMP on the disk in drive A and position the file pointers at the existing data. Now we can add records to the file, which has been numbered as 1.
Following example will illustrate the use a of Append

Example 4
Write a program to add two more products to the file "INVENT. DTA" created earlier in Example 1.
DDDD 104 20.0 200
EEEE 105 30.0 300

Program
10 FILES = "INVENT. DTA"
20 OPEN FILES FOR APPEND AS #1
30 FOR I=1 TO 2
40 INPUT PNM$, PN, P, QTY
50 WRITE #1, PNM$, PN, P, QTY
60 NEXT I
70 CLOSE # 1
80 REM ** DATA INPUT FROM FILES **
90 OPEN "I", #1, "INVENT. DTA
100 PRINT
110 IF EOF (1) THEN 160
120 INPUT #1, PNM$, PN, P, QTY
130 PRINT PNM$, PN, P, QTY
140 GOTO 110
150 CLOSE # 1
160 END

Output
? DDDD, 104, 20, 200
? EEEE, 105, 30, 300

AAAA 101 8 100
BBBB 102 10 200
CCCC 103 12 300
DDDD 104 20 200
EEEE 105 30 300

QBASIC

Number Guesser
In this game, the computer picks a number between 1 and 10. You have to try and guess the number.
CLS
RANDOMIZE TIMER
PRINT "Welcome to Number Guesser"
PRINT "I'm thinking of a number between 1 and 10."
Number = INT(RND * 10 + 1)
DO
INPUT "What is your guess? ", Guess
IF Guess = Number THEN
PRINT "Correct!"
EXIT DO
ELSE
PRINT "Try again"
END IF
LOOP
END
DATA STRUCTURE
Single-Precision:
The single-precision type handles numbers with decimals. You can go up to seven digits with a single-precision variable. In a DIM statement, use "SINGLE" to create a single-precision variable. The type-character for a single-precision variable is "!". Unless you do something special, any variable without a type character is single-precision. Here are some examples of creating and using single-precision variables: X = 1.5
DIM Y AS SINGLE
Y = 2.1
Z! = 2.5
PRINT X; Y; Z!
Notice that the DIM statement can be used to tell QBASIC the type of a variable. Then you don't need to use a type character for that variable.
String:
The string type handles strings of characters. You cannot do math with string variables. In a DIM statement, use "STRING" to create a string variable. The type-character for a string variable is "$". Here are some examples of creating and using string variables: X$ = "Hello"
DIM Y AS STRING
Y = "Goodbye"
PRINT X$
PRINT Y
Integer:
The integer type handles numbers without decimals. Integers may range from -32768 to 32767. Math with integers may be faster than math with single-precision variables. For programs that have to run very fast, using integers might be useful. In a DIM statement, use "INTEGER" to create an integer variable. The type-character for an integer variable is "%". Here are some examples of creating and using integer variables: X% = 32
DIM Y AS INTEGER
Y = 55
PRINT X%; Y
Since math with integers is very fast, you will commonly see the following line near the beginning of QBASIC programs: DEFINT A-Z
This tells QBASIC to stop assuming that every variable is single-precision, and instead to assume that all variables are integers. This way you don't need to use DIM or the "%" symbol throughout your program to make all your variables integers.
Long-Integer:
The long-integer type handles numbers without decimals. Long-integers may range from -2147483648 to 2147483647. Math with long-integers is usually almost as fast as math with integers. For programs that have to run very fast, using long-integers might be useful. In a DIM statement, use "LONG" to create a long-integer variable. The type-character for a long-integer variable is "&". Here are some examples of creating and using long-integer variables: X& = 65536
DIM Y AS LONG
Y = 121072
PRINT X&; Y
Double-Precision:
The double-precision type handles numbers with decimals. You can go up to fifteen digits with a double-precision variable. Double-precision variables are used where very accurate math is needed. In a DIM statement, use "DOUBLE" to create a double-precision variable. The type-character for a double-precision variable is "#". Here are some examples of creating and using double-precision variables: X# = 3.14159265358979
DIM Y AS DOUBLE
Y = 1.23456789012345
PRINT X#; Y
SELECT CASE
IF...THEN...ELSE is fine if you only have two things you want to check. What if you have 5 or 6 friends that might use your computer and you want the computer to say something different to each of them? Try this:
CLS
INPUT "Enter your name: ", Name$
SELECT CASE Name$
CASE "Ted"
PRINT "Greetings, oh powerful master"
CASE "Mike"
PRINT "Go away!"
CASE ELSE
PRINT "Hello, "; Name$; ". How are you?"
END SELECT
Whew, that was a big one. Fortunately we learned how to save in Chapter 8. Save it if you want before running it. Feel free to change "Ted" and "Mike" to "Laura" and "Robin" or whoever.
SELECT CASE can also be used with numbers as well as strings. Here's a quick example:
CLS
INPUT "Enter a number: ", Number
SELECT CASE Number
CASE 1234
PRINT "Thank you for entering the secret number 1234"
CASE 22
PRINT "Well, 22 is an interesting number"
CASE ELSE
PRINT "You must not know the secret number"
END SELECT

Computer & History

Introduction:
A computer is a machine for manipulating data according to a list of instructions, or program.
Computers take numerous physical forms. Early electronic computers were the size of a large room, consuming as much power as several hundred modern personal computers. [1] Today, computers can be made small enough to fit into a wrist watch and be powered from a watch battery. However, large-scale computing facilities still exist for specialized scientific computation and for the transaction processing requirements of large organizations. Society has come to recognize personal computers and their portable equivalent, the laptop computer, as icons of the information age; they are what most people think of as "a computer". However, the most common form of computer in use today is by far the embedded computer. Embedded computers are small, simple devices that are often used to control other devices—for example, they may be found in machines ranging from fighter aircraft to industrial robots, digital cameras, and even children's toys.
The ability to store and execute programs—that is, programmability—makes computers extremely versatile and distinguishes them from calculators. The Church–Turing thesis is a mathematical statement of this versatility: Any computer with a certain minimum capability is, in principle, capable of performing the same tasks that any other computer can perform. Therefore, computers with capability and complexity ranging from that of a personal digital assistant to a supercomputer are all able to perform the same computational tasks so long as time and storage capacity are not considerations.

History:
It is difficult to define any one device as the earliest computer. The very definition of a computer has changed and it is therefore impossible to identify the first computer. Many devices once called "computers" would no longer qualify as such by today's standards.
Originally, the term "computer" referred to a person who performed numerical calculations (a human computer), often with the aid of a mechanical calculating device. Examples of early mechanical computing devices included the abacus, the slide rule and arguably the astrolabe and the Antikythera mechanism (which dates from about 150-100 BC). The end of the Middle Ages saw a re-invigoration of European mathematics and engineering, and Wilhelm Schickard's 1623 device was the first of a number of mechanical calculators constructed by European engineers.
However, none of those devices fit the modern definition of a computer because they could not be programmed. In 1801, Joseph Marie Jacquard made an improvement to the textile loom that used a series of punched paper cards as a template to allow his loom to weave intricate patterns automatically. The resulting Jacquard loom was an important step in the development of computers because the use of punched cards to define woven patterns can be viewed as an early, albeit limited, form of programmability.
In 1837, Charles Babbage was the first to conceptualize and design a fully programmable mechanical computer that he called "The Analytical Engine".[2] Due to limited finance, and an inability to resist tinkering with the design, Babbage never actually built his Analytical Engine.
Large-scale automated data processing of punched cards was performed for the US Census in 1890 by tabulating machines designed by Herman Hollerith and manufactured by the Computing Tabulating Recording Corporation (CTR), which later became IBM. By the end of the 19th century a number of technologies that would later prove useful in the realization of practical computers had begun to appear: the punched card, boolean algebra, the vacuum tube (thermionic valve) and the teleprinter.
During the first half of the 20th century, many scientific computing needs were met by increasingly sophisticated analog computers, which used a direct mechanical or electrical model of the problem as a basis for computation. However, these were not programmable and generally lacked the versatility and accuracy of modern digital computers.
A succession of steadily more powerful and flexible computing devices were constructed in the 1930s and 1940s, gradually adding the key features that are seen in modern computers. The use of digital electronics (largely invented by Claude Shannon in 1937) and more flexible programmability were vitally important steps, but defining one point along this road as "the first digital electronic computer" is difficult (Shannon 1940). Notable achievements include:
The Atanasoff-Berry Computer (1941) which used vacuum tube based computation, binary numbers, and regenerative capacitor memory.
Konrad Zuse's electromechanical "Z machines". The Z3 (1941) was the first working machine featuring binary arithmetic and a measure of programmability.
The secret British Colossus computer (1944), which had limited programmability but demonstrated that a device using thousands of tubes could be reasonably reliable and electronically reprogrammable. It was used for breaking German wartime codes.
The Harvard Mark I (1944), a large-scale electromechanical computer with limited programmability.
The US Army's Ballistics Research Laboratory ENIAC (1946), which used decimal arithmetic and was the first general purpose electronic computer, although it initially had an inflexible architecture which essentially required rewiring to change its programming.
Several developers of ENIAC, recognizing its flaws, came up with a far more flexible and elegant design, which came to be known as the stored program architecture or von Neumann architecture. This design was first formally described by John von Neumann in the paper "First Draft of a Report on the EDVAC", published in 1945. A number of projects to develop computers based on the stored program architecture commenced around this time, the first of these being completed in Great Britain. The first to be demonstrated working was the Manchester Small-Scale Experimental Machine (SSEM) or "Baby". However, the EDSAC, completed a year after SSEM, was perhaps the first practical implementation of the stored program design. Shortly thereafter, the machine originally described by von Neumann's paper—EDVAC—was completed but didn't see full-time use for an additional two years.
Nearly all modern computers implement some form of the stored program architecture, making it the single trait by which the word "computer" is now defined. By this standard, many earlier devices would no longer be called computers by today's definition, but are usually referred to as such in their historical context. While the technologies used in computers have changed dramatically since the first electronic, general-purpose computers of the 1940s, most still use the von Neumann architecture. The design made the universal computer a practical reality.
Vacuum tube-based computers were in use throughout the 1950s, but were largely replaced in the 1960s by transistor-based devices, which were smaller, faster, cheaper, used less power and were more reliable. These factors allowed computers to be produced on an unprecedented commercial scale. By the 1970s, the adoption of integrated circuit technology and the subsequent creation of microprocessors such as the Intel 4004 caused another leap in size, speed, cost and reliability. By the 1980s, computers had become sufficiently small and cheap to replace simple mechanical controls in domestic appliances such as washing machines. Around the same time, computers became widely accessible for personal use by individuals in the form of home computers and the now ubiquitous personal computer. In conjunction with the widespread growth of the Internet since the 1990s, personal computers are becoming as common as the television and the telephone and almost all modern electronic devices contain a computer of some kind.

Database - III

Database Objects
Access database is made up of different Objects like tables, queries, forms, reports, data access pages, macros and modules. Each of the above Objects has their own special function different from one another. While working with Access you will include several objects like relationships, command bars, database properties etc.

Tables
Tables are grids that store information in a database similar to the way an Excel worksheet stores information in a workbook. Table is the first object that you add to your database is used to store all the data in the database. Each row of a table contains one record. Records are made up of fields that contain a particular piece of data in the table. Every table in Access 2000 must have a field that uniquely identifies each record in the table. This field is called the primary key. You can recognize the primary key in a table by the ID appended to it. The primary key ensures that you can retrieve data accurately and efficiently when you pull information from the database.

Queries
Queries in Access are Powerful and versatile. Using select queries you can view, summarize and perform calculations on the data of your table (single or multiple). And Action queries lets you add, update and delete data from table. When a select query is run, a datasheet appears, with the specified fields in the query and the records meeting the query’s criteria. When an action query is run, the specified action is run such as appending data to an existing table, deleting data from table or updating data of an existing table. The query created is stored as a separate object and listed in the database window.
The datasheet returned by a query is a dynamic set of data, called dynaset, and can be updated based on the tables data.

Forms
Forms are used to view, enter, edit and print table data in a custom format. Form can be created form the data of a query result also. It provides more structured view of the data as compared to datasheet view and can be used to add, change, delete or view database records, one record at a time. Using Forms, user can navigate through the records, access to certain fields can be restricted, validation rule can also be set and custom dialog box can be created that can be used to display or retrieve information from the users. Forms are comprised of following three sections:
Header - Header may be Page header or Form header. Page Header is displayed when the form is Printed and Form header is displayed when the form is viewed in the form view.
Detail - Detail area contains the entire contents of your form design.
Footer - Footer may be Page footer or Form footer. Page footer is displayed when the form is Printed and Form footer is displayed when the form is viewed in the form view.

Reports
Report is a comprehensive tool of Access that is used to create and maintain report of facts about the data in a clear and concise form. Reporting is one of the primary purposes of a database programme and can contain data from multiple tables. With Access you can create Detail report, Summary report, Cross-tabulation report, Report containing graphics, charts, forms, labels etc. Similar to Forms Reports is also comprised of three sections:
Header - Header may be Page header or Report header. Page Header is displayed at the top of a page when the report is printed and Report header is displayed at the top of a report.
Detail - Detail area contains the entire contents of your report.
Footer - Footer may be Page footer or Report footer. Page footer is displayed at the top of a page when the report is printed and Report footer is displayed at the bottom of a report.

Pages
Pages allow you to view and update the data in your database from within a browser. Although they are stored outside the Access database (.mdb) file, they are created and maintained in a manner similar to that of forms. Although the data access pages are targeted toward browser, they can also be previewed within the Access application environment. Data access Pages can also be viewed and modified in Design View. Design View of a Data access page is similar to that of a form, which makes working with the data access Pages and deployment of your application over an Intranet, very easy.

Macros
Macros in Access differ from the macros of the other languages. They can't be recorded as in Word or Excel and are not saved as VBA code. With Access macros, you can perform most of the task that you perform manually from keyboard, menus and toolbars. Generally VBA (Visual Basic for Applications) code contained in module are used rather than macros to do the task that your application must perform. VBA code gives more flexibility and power than macro.

Modules
Modules are the foundation of any application and let you create libraries of functions that can be used throughout your application. Modules contains the VBA code and you can do the following using it:
· Perform error handling
· Declare and use variables
· Loop through and manipulate record sets
· Call Windows API and other library functions
· Create and modify system objects, like tables and queries
· Perform transaction processing
· Perform many functions not available with macros
· Test and debug complex process
· Create library database

Database - II

Microsoft Access 2000/XP
Microsoft Access 2000 is a powerful multi-user RDBMS (Relational Database Management system) developed by Microsoft Corporation and can be used to store and manipulate large amounts of information and perform repetitive tasks. Access creates desktop and client/server database applications that run under the Windows operating system and stores an entire database application within a single file with a .mdb extension, which can contain data objects, like tables, indexes and queries, as well as application objects like forms, reports, macros, and visual basic code. Although the term “database” typically refers to a collection of related data tables, an Access database includes more than just data. In addition to tables, an Access database file contains several different types of database objects:
- Saved queries for organizing data,
- Forms for interacting with the data on screen,
- Reports for printing results,
Microsoft Access 2000 offers a variety of features for different database needs and can be used to different types of applications such as:
- Personal Applications
- Small Business Applications
- Departmental Applications
- Corporation-wide Applications
- As a front end for enterprise wide client/server Applications
- Intranet / Internet Applications
Data in Access is organized using tables and in the table records are arranged according to a common reference value, which is different for every record and uniquely identifies the records. This common reference value is called primary key or key Field.
Sometimes more than one field has to be used to uniquely identify a record, i.e. Primary Key may contain more than one field. Such type of Primary Key is called Composite Key.

Database - I

DBMS(Database Management System)
A database-management system (DBMS) consists of a collection of interrelated data and a set of programs to access those data. The collection of data, usually referred to as the database, contains information about one particular enterprise. The Primary goal of a DBMS is to provide an environment that is both convenient and efficient to use in retrieving and storing database information.
Database
A database is a collection of related data or facts. A database is a collection of data organized in a manner, which allows retrieval and use of that data, by anyone needing it. A database is a repository for collections of related data or facts. A database is organized and designed to allow a large number of users to draw information from it for many different purposes in many different formats.
Database systems are designed to manage large bodies of information. The management of data involves both the definition of structures fro the storage of information and the provision of mechanisms for the manipulation of information. In addition, the database system must provide for the safety of the information stored, despite system crashes or attempts at unauthorized access. If data are to be shared among several users, the system must avoid possible anomalous results. The importance of information in most organizations - which determines the value of the database - has led to the development of a large body of concepts and techniques for the efficient management of data. Some popular DBMS are FoxPro, Clipper, Sybase etc.

RDBMS(Relaltional Database Management System):
Relational Database Management System is a specialized computer program, where the data are split in tables to reduce data redundancy and get consistency in data. Relational database is based on the relational database model, which was introduced in 1970 by E.F. Code. The model is based on mathematical theory, especially on the disciplines of Set Theory and Predicate Logic. The basic idea behind the relational model is that a database consists of a series of unordered tables (or, relations) that can be manipulated using nonprocedural operations. This model was in vast contrast to the more traditional database theories of the time, which were more complicated and less flexible and were dependent on the physical methods used to store the data. Relational approach uses the computer to search the database for the desired data rather than accessing data through series of indices and physical addresses. In RDBMS the data structure or relationship between data are defined in logical rather than physical terms.
Note: It is commonly thought that the word 'Relational' in the Relational Model comes from the fact that you relate tables to each other in a relational database. Although this is a convenient way to think of the term, it's not accurate. Some of the popular RDBMS are MS-Access, MS-SQL Server, and ORACLE etc.