computer in management

32
CONTROL UNIT  The control unit maintains order within the computer system and dire cts the flow of traffic(ope rations) and data. The flow of control is indicated by the dotted arrows on figure 1-1. The control unit selects one program statement at a time from the program storage area, interprets the statement, and sends the appropriate electronic impulses to the arithmetic-logic unit and storage section to cause them to carry out the instruction. The control unit does not perform the actual processing operations on the data. Specifically, the control unit manages the operations of the CPU, be it a single-chip microprocessor or a fill-size mainframe. Like a traffic director, it decides when to start and s top(control and timing), what to do (program instructions),where to keep information (memory), and with what devices to communicate (I/O). It controls the flow of all data entering and leaving the computer. It accomplishes this by communicating or inte rfacing with the arithmetic-l ogic unit , memory, and I/O areas. It provides the computer with the ability to function under program control. Depending on the design of the computer, t he CPU can also have the capability t o function under manual control through man/machine interfacing. The control unit consists of several basic logically defined areas. These logically defined areas work closely with each other. Timing in a computer regulates the flow of signals that control the operation of the computer. The instruction and control portion makes up the decision- making and memory- type functions. Addressing is t he process of locating the operand(specific information) for a given operation. An interrupt is a break in the normal flow of operation of a computer (e.g., CTRL + ALT + DEL). Control memory is a random-access memory (RAM)consisting of addressable storage registers. Cache memory i s a small, high-speed RAM buf fer located between the CPU and main memory; it can increase the speed of the PC. Read-only memory (ROM) are chips with a set of software instructions supplied by the manufacturer built into them that enables the computer to perform its I/O operations.  The control unit is also capable of shutting down the computer when the power supply detects abnormal conditions. ARITHMETIC-LOGIC UNIT  The arithmetic-logic unit (ALU) performs all arithmetic operations (addition, subtraction, multiplication , and division) and logic operations. Logic operations test various conditions encountered during processing and allow for different actions to betaken based on the results. The data required to perform the arithmetic and logical functions are inputs from the designated CPU registers and operands. The ALU relies on basic items to perform its operations . These include number systems, data routing circuits (adders/sub tracters), timing, instructions, operands, and registers. Figure 1-2 shows are presentat ive block diagram of an ALU of a micro computer. PRIMARY STORAGE (MAIN MEMORY)The primary storage section (also called internal storage, main storage, main memory, or just memory)serves four purposes:. To hold data transferred from

Upload: shaequeazam

Post on 08-Apr-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 1/32

CONTROL UNIT

  The control unit maintains order within the computer system and directs

the flow of traffic(operations) and data. The flow of control is indicated by the

dotted arrows on figure 1-1. The control unit selects one program statement

at a time from the program storage area, interprets the statement, and

sends the appropriate electronic impulses to the arithmetic-logic unit andstorage section to cause them to carry out the instruction. The control unit does

not perform the actual processing operations on the data. Specifically, the

control unit manages the operations of the CPU, be it a single-chip microprocessor o

a fill-size mainframe. Like a traffic director, it decides when to start and stop(contro

and timing), what to do (program instructions),where to keep information

(memory), and with what devices to communicate (I/O). It controls the flow of all

data entering and leaving the computer. It accomplishes this by communicatin

or interfacing with the arithmetic-logic unit, memory, and I/O areas. It

provides the computer with the ability to function under program control. Depending

on the design of the computer, the CPU can also have the capability tofunction under manual control through man/machine interfacing. The control unit

consists of several basic logically defined areas. These logically defined areas wor

closely with each other. Timing in a computer regulates the flow of signals that

control the operation of the computer. The instruction and control portion makes u

the decision-making and memory-type functions. Addressing is the process of 

locating the operand(specific information) for a given operation. An interrup

is a break in the normal flow of operation of a computer (e.g., CTRL + ALT + DEL

Control memory is a random-access memory (RAM)consisting of addressable

storage registers. Cache memory is a small, high-speed RAM buffer locatedbetween the CPU and main memory; it can increase the speed of the PC. Read-only

memory (ROM) are chips with a set of software instructions supplied by the

manufacturer built into them that enables the computer to perform its I/O operations.

 The control unit is also capable of shutting down the computer when the power

supply detects abnormal conditions.

ARITHMETIC-LOGIC UNIT

  The arithmetic-logic unit (ALU) performs all arithmetic operations (addition,

subtraction, multiplication , and division) and logic operations. Logic

operations test various conditions encountered during processing and allow for

different actions to betaken based on the results. The data required to perform the

arithmetic and logical functions are inputs from the designated CPU registers and

operands. The ALU relies on basic items to perform its operations . These

include number systems, data routing circuits (adders/sub tracters), timing,

instructions, operands, and registers. Figure 1-2 shows are presentative bloc

diagram of an ALU of a micro computer. PRIMARY STORAGE (MAIN

MEMORY)The primary storage section (also called internal storage, main storage,

main memory, or just memory)serves four purposes:. To hold data transferred from

Page 2: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 2/32

an I/O device to the input storage area, where it remains until the computer is ready

to process it. This is indicated by the solid arrow on figure 1-1.. To hold both the

data being processed and the intermediate results of the arithmetic- logic

operations . This is a working storage area within the storage section. It is

sometimes referred to as a scratch pad memory.. To hold the processing results

in an output storage area for transfer to an I/O device.

Figure 1-2.—Representative block diagram of an ALU.

Software Define

Software is a general term for the various kinds of programs used to operatecomputers and related devices. (The term hardware describes the physical aspects ofcomputers and related devices.) Software is a generic term for programs that are useby computers and other products that contain logic circuitry (i.e., embedded systemsIn a broader sense it can also refer to all information (i.e., both programs and data) inelectronic form, and it can provide a distinction from hardware, which refers to mediaand systems on which software can exist and be used.

variable

In programming, a variable is a value that can change, depending on conditions or oninformation passed to the program. Typically, a program consists of instruction s that

tell the computer what to do and data that the program uses when it is running. Thedata consists of constants or fixed values that never change and variable values(which are usually initialized to "0" or some default value because the actual valueswill be supplied by a program's user). Usually, both constants and variables aredefined as certain data type s. Each data type prescribes and limits the form of thedata. Examples of data types include: an integer expressed as a decimal number, or astring of text characters, usually limited in length.

In object-oriented programming , each object contains the data variables of the classis an instance of. The object's method s are designed to handle the actual values thatare supplied to the object when the object is being used.

Page 3: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 3/32

ARRAYS

An array is data structure (type of memory layout) that stores a collection of individua

values that are of the same data type. Arrays are useful because instead of having to

separately store related information in different variables (named memory locations),

you can store them—as a collection—in just one variable. It is more efficient for a

program to access and process the information in an array, than it is to deal with manseparate variables.

All of the items placed into an array are automatically stored in adjacent memory

locations. As the program retrieves the value of each item (or "element") of an array,

simply moves from one memory location to the very next—in a sequential manner. It

doesn't have to keep jumping around to widely scattered memory locations in order t

retrieve each item's value.

FUNCTIONS

"Less code,more work" shows the performance/standard of the program.

ADVANTAGES:

*It reduces the Complexity in a program by reducing the code.

*It also reduces the Time to run a program.In other way,Its directly proportional to

Complexity.

*Its easy to find-out the errors due to the blocks made as function definition outside

the main function.

POINTER

In C language, a pointer is a variable that points to or references a memory location inwhich data is stored. Each memory cell in the computer has an address which can beused to access its location. A pointer variable points to a memory location. By makinuse of pointer, we can access and change the contents of the memory location.

Pointer declaration:

A pointer variable contains the memory location of another variable. You begin thedeclaration of a pointer by specifying the type of data stored in the location identifiedby the pointer. The asterisk tells the compiler that you are creating a pointer variableFinally you give the name of the pointer variable. The pointer declaration syntax is a

shown below.

type * variable nameExample:

int *ptr;float *string;

Pointers and function:

 The pointer are very much used in a function declaration. Sometimes only with apointer a complex function can be easily represented and success. The usage of thepointers in a function definition may be classified into two groups.

Page 4: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 4/32

1. Call by reference2. Call by value.

Call by value:

We have seen that a function is invoked there will be a link established between theformal and actual parameters. A temporary storage is created where the value of 

actual parameters is stored. The formal parameters picks up its value from storagearea the mechanism of data transfer between actual and formal parameters allows thactual parameters mechanism of data transfer is referred as call by value. Thecorresponding formal parameter represents a local variable in the called function. Thecurrent value of corresponding actual parameter becomes the initial value of formalparameter. The value of formal parameter may be changed in the body of the actualparameter. The value of formal parameter may be changed in the body of thesubprogram by assignment or input statements.

This will not change the value of actual parameters./* Include <stdio.h>void main(){int x,y;x=20;y=30;printf(“n Value of a and b before function call =%d %d”,a,b);fncn(x,y);printf(“n Value of a and b after function call =%d %d”,a,b);}

fncn(p,q)int p,q;{p=p+p;q=q+q;}

Call by Reference:

When we pass address to a function the parameters receiving the address should be

pointers. The process of calling a function by using pointers to pass the address of thevariable is known as call by reference. The function which is called by reference canchange the values of the variable used in the call.

/* example of call by reference*?

/* Include <stdio.h>

void main()

{

int x,y;

Page 5: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 5/32

x=20;

y=30;

printf(“n Value of a and b before function call =%d %d”,a,b);

fncn(&x,&y);

printf(“n Value of a and b after function call =%d %d”,a,b);

}

fncn(p,q)

int p,q;

{

*p=*p+*p;

*q=*q+*q;

}

Introducing to C structure

In some programming contexts, you need to access multiple data types under a singlname for easier data manipulation; for example you want to refer to address withmultiple data like house number, street, zip code, country. C supports structure whichallows you to wrap one or more variables with different data types. A structure cancontain any valid data types like int, char, float even arrays or even other structures.Each variable in structure is called a structure member.

Defining structure To define a structure, you use struct keyword. Here is the common syntax of structur

definition:struct struct_name{ structure_member }; The name of structure follows the rule of variable name. Here is an example of defining address structure:struct address{

unsigned int house_nu

mber;

char street_name

[50];

int zip_code;

char country[

50];

};

 The address structure contains house number as an positive integer, street name as astring, zip code as an integer and country as a string.

Page 6: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 6/32

Declaring structure The above example only defines an address structure without creating any structureinstance. To create or declare a structure instance, you can do it in two ways: The first way is to declare a structure followed by structure definition like this :struct struct_nam

e {

structure_member;

...

} instance_1,instance_2

instance_n;

In the second way, you can declare the structure instance at a different location inyour source code after structure definition. Here is structure declaration syntax :

1

struct struct_name instance_1,instance_2

instance_n;

FILE HANDLEING FUNCTION IN C

In any programming language it is vital to learn file handling techniques. Manyapplications will at some point involve accessing folders and files on the hard drive. InC, a stream is associated with a file. Special functions have been designed for handlin

file operations. Some of them will be discussed in this chapter. The header file stdio.his required for using these functions.

Opening a file

Before we perform any operations on a file, we need to identify the file to the systemand open it. We do this by using a file pointer. The type FILE defined in stdio.h allowsus to define a file pointer.Then you use the function fopen() for opening a file. Oncethis is done one can read or write to the file using the fread() or fwrite() functions,respectively. The fclose() function is used to explicitly close any opened file.

 Taking the preceding statements into account let us look at the following exampleprogram :

Program 13.1

#include

main (){

Page 7: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 7/32

FILE *fp;fp = fopen("data.txt", "r")if (fp == NULL) {printf("File does not exist,

please check!\n");}

fclose(fp);}

fopen()

Let us first discuss fopen(). This function accepts two arguments as strings. The firstargument denotes the name of the file to be opened and the second signifies themode in which the file is to be opened. The second argument can be any of thefollowing:

File Mode Description

r Open a text file for reading

wCreate a text file for writing, if it exists, it is

overwritten.

aOpen a text file and append text to the end of the

file.

rb Open a binary file for reading

wbCreate a binary file for writing, if it exists, it is

overwritten.

abOpen a binary file and append data to the end of the

file.

 

fclose()

 The fclose() function is used for closing opened files. The only argument it accepts isthe file pointer.

If a program terminates, it automatically closes all opened files. But it is a goodprogramming habit to close any file once it is no longer needed. This helps in betterutilization of system resources, and is very useful when you are working on numerousfiles simultaneously. Some operating systems place a limit on the number of files thatcan be open at any given point in time.

Page 8: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 8/32

fscanf() and fprintf()

 The functions fprintf() and fscanf() are similar to printf() and scanf() except that thesefunctions operate on files and require one additional and first argument to be a filepointer.

Program 13.2

#include

main (){FILE *fp;float total;fp = fopen("data.txt", "w+")if (fp == NULL) {printf("data.txt does not exist, please check!\n");exit (1);

}fprintf(fp, 100);fscanf(fp, "%f", &total);fclose(fp);printf("Value of total is %f\n", total);

}

getc() and putc()

 The functions getc() and putc() are equivalent to getchar() and putchar() functionswhich you studied in Chapter 12 on Input and Output, except that these functionsrequire an argument which is the file pointer. Function getc() reads a single characterfrom the file which has previously been opened using a functionlike fopen(). Function putc() does the opposite, it writes a character to the fileidentified by its second argument. The format of both functions is as follows :

getc(in_file);putc(c, out_file);

Note: The second argument in the putc() function must be a file opened in either write

or append mode.

#include

main (){char in_file[30], out_file[30];FILE *fpin, *fpout;

Page 9: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 9/32

int c;printf("This program copies the source file to the destination file

\n\n");printf("Enter name of the source file :");scanf("%30s", in_file);printf("Enter name of the destination file :");

scanf("%30s", out_file);if((fpin=fopen(in_file, "r")) == NULL)printf("Error could not open source file for

reading\n");else if ((fpout=fopen(out_file, "w")) == NULL)printf("Error could not open destination file for

reading\n");else{while((c =getc(fpin)) != EOF)putc(c, fpout);

printf("Destination file has been copied\n");}

}

Binary stream input and output 

 The functions fread() and fwrite() are a somwhat complex file handling functions usedfor reading or writing chunks of data containing NULL charactesr ('\0') terminatingstrings.

 The function prototype of fread() and fwrite() is as below :

size_t fread(void *ptr, size_t sz, size_t n, FILE *fp)size_t fwrite(const void *ptr, size_t sz, size_t n, File *fp);

 You may notice that the return type of fread() is size_t which is the number of itemsread. You will understand this once you understand how fread() works. Itreads n items, each of size sz from a file pointed to by the pointer fp into a bufferpointed by a void pointer ptr which is nothing but a generic pointer.Function fread() reads it as a stream of bytes and advances the file pointer by thenumber of bytes read. If it encounters an error or end-of-file, it returns a zero, youhave to use feof() or ferror() to distinguish between these two. Function fwrite() workssimilarly, it writes n objects of sz bytes long from a file pointed to by fp to a locationpointed to by ptr , and returns the number of items written to fp.

GENERATIONS OF COMPUTERS

Page 10: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 10/32

 The history of computer development is often referred to in reference to the different

generations of computing devices. Each generation of computer is characterized by a

major technological development that fundamentally changed the way computers

operate, resulting in increasingly smaller, cheaper, more powerful and more efficient

and reliable devices. Read about each generation and the developments that led to

the current devices that we use today.

First Generation (1940-1956) Vacuum Tubes The first computers used vacuum tubes for circuitry and magnetic drums for memoryand were often enormous, taking up entire rooms. They were very expensive tooperate and in addition to using a great deal of electricity, generated a lot of heat,which was often the cause of malfunctions.First generation computers relied on machine language, the lowest-level programminlanguage understood by computers, to perform operations, and they could only solveone problem at a time. Input was based on punched cards and paper tape, and outpuwas displayed on printouts. The UNIVAC and ENIAC computers are examples of first-generation computing device

 The UNIVAC was the first commercial computer delivered to a business client, the U.SCensus Bureau in 1951.

Second Generation (1956-1963) Transistors Transistors replaced vacuum tubes and ushered in the second generation of computers. The transistor was invented in 1947 but did not see widespread use incomputers until the late 1950s. The transistor was far superior to the vacuum tube,allowing computers to become smaller, faster, cheaper, more energy-efficient andmore reliable than their first-generation predecessors. Though the transistor stillgenerated a great deal of heat that subjected the computer to damage, it was a vastimprovement over the vacuum tube. Second-generation computers still relied on

punched cards for input and printouts for output.Second-generation computers moved from cryptic binary machine language tosymbolic, or assembly, languages, which allowed programmers to specify instructionsin words. High-level programming languages were also being developed at this time,such as early versions of COBOL and FORTRAN. These were also the first computersthat stored their instructions in their memory, which moved from a magnetic drum tomagnetic core technology. The first computers of this generation were developed for the atomic energy industryThird Generation (1964-1971) Integrated Circuits The development of the integrated circuit was the hallmark of the third generation of computers. Transistors were miniaturized and placed on silicon chips,

called semiconductors, which drastically increased the speed and efficiency of computers.Instead of punched cards and printouts, users interacted with third generationcomputers through keyboards and monitorsand interfaced with an operating system,which allowed the device to run many different applications at one time with a centraprogram that monitored the memory. Computers for the first time became accessibleto a mass audience because they were smaller and cheaper than their predecessors.

Fourth Generation (1971-Present) Microprocessors The microprocessor brought the fourth generation of computers, as thousands of integrated circuits were built onto a single silicon chip. What in the first generation

Page 11: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 11/32

Page 12: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 12/32

worksheet in the group. So, if you have grouped Sheet1, Sheet2 and Sheet3, entering

text in cellA1 on Sheet1 also enters the same text in

the corresponding cells on Sheet2 and Sheet3.

Any choices you make such as applying a number format, affect all the grouped

worksheets identically. If you are building a workbook with identically formatted

sheets, you can use thesetechniques to quickly enter category headings, etc. along the top of each sheet. You cannot use the Clipboard to enter data into multiple sheets concurrently. Whenyou paste data, it only appears in the active sheet and not in any other sheets youhave selected.

STRUCTURES

Arrays are used to store large set of data and manipulate them but the disadvantage

is that all the elements stored in an array are to be of the same data type. If we need

to use a collection of different data type items it is not possible using an array. Whenwe require using a collection of different data items of different data types we can us

a structure. Structure is a method of packing data of different types. A structure is a

convenient method of handling a group of related data items of different data types.

Unformatted console I/O functions. 

 The functions under this category are :getch() putch() gets()

getche() putchar() puts()getchar() fputchar()fgetchar()

 These above listed function broadly fall into two categories, the one which deal with asingle character and the second which deal with a string of characters.

Explanations :

getch() : This function will read a single character the instant it is typed by

programmer without waiting for the Enter Key to be hit. The typed character is notechoed on screen.

getche() : This function will also read a single character the instant it is typed byprogrammer without waiting for the Enter key to be hit, just like getch() function. Theadditional character 'e' in function getch() echoes the character on screen that youtyped. This is a point of differences between getch() & getche().

getchar() : It works similar to that of getch() and also echoes the character you typedon the screen but it also requires enter key to be hit immediately after the characterthat you typed. It is a macro.

Page 13: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 13/32

fgetchar() : It will echo the character on screen and it requires hit of Enter keyimmediately following the character. The only difference between getchar() andfgetchar() is that the former is a macro and latter is function.

putch() : It writes a character to the screen.

putchar() : It writes a character to the screen and is a macro.

fputchar() : It writes a character to the screen (function version).

(Note : putch(), putchar() and fputchar() can output only one character at a time onscreen.)

gets() : It gets a string from the keyboard and it is necessary on programmers part toterminates that string with an Enter key. That's why spaces and tabs are acceptable aa part of the input string if any gets() is used to read only one string at a time.

puts() : It outputs a string to the screen puts() can outputs only one string at a time.

Arrays and multidimensional arrays

ArraysAn array is a series of elements of the same type placed in contiguous memory

locations that can be individually referenced by adding an index to a unique identifier

 That means that, for example, we can store 5 values of type int in an array without

having to declare 5 different variables, each one with a different identifier. Instead of 

that, using an array we can store 5 different values of the same type, int for example,with a unique identifier.

For example, an array to contain 5 integer values of type int called billy could be

represented like this:

 

where each blank panel represents an element of the array, that in this case are

integer values of type int. These elements are numbered from 0 to 4 since in arrays

the first index is always 0, independently of its length.

Like a regular variable, an array must be declared before it is used. A typical

declaration for an array in C++ is:

type name [elements];

Page 14: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 14/32

where type is a valid type (like int, float...), name is a valid identifier and

the elements field (which is always enclosed in square brackets []), specifies how

many of these elements the array has to contain.

 Therefore, in order to declare an array called billy as the one shown in the above

diagram it is as simple as:

  int billy[5];

NOTE: The elements field within brackets [] which represents the number of elements

the array is going to hold, must be a constant value, since arrays are blocks of non-

dynamic memory whose size must be determined before execution. In order to create

arrays with a variable length dynamic memory is needed, which is explained later in

these tutorials.

Initializing arrays.

When declaring a regular array of local scope (within a function, for example), if we d

not specify otherwise, its elements will not be initialized to any value by default, so

their content will be undetermined until we store some value in them. The elements o

global and static arrays, on the other hand, are automatically initialized with their

default values, which for all fundamental types this means they are filled with zeros.

In both cases, local and global, when we declare an array, we have the possibility to

assign initial values to each one of its elements by enclosing the values in braces { }.

For example:

  int billy [5] = { 16, 2, 77, 40,12071 };

 This declaration would have created an array like this:

  The amount of values between braces { } must not be larger than the number of 

elements that we declare for the array between square brackets [ ]. For example, in

the example of array billy we have declared that it has 5 elements and in the list of 

initial values within braces { } we have specified 5 values, one for each element.

When an initialization of values is provided for an array, C++ allows the possibility of 

leaving the square brackets empty [ ]. In this case, the compiler will assume a size for

the array that matches the number of values included between braces { }:

Page 15: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 15/32

  int billy [] = { 16, 2, 77, 40,12071 };

After this declaration, array billy would be 5 ints long, since we have provided 5

initialization values.

Accessing the values of an array.

In any point of a program in which an array is visible, we can access the value of any

of its elements individually as if it was a normal variable, thus being able to both read

and modify its value. The format is as simple as:

name[index]

Following the previous examples in which billy had 5 elements and each of those

elements was of type int, the name which we can use to refer to each element is thefollowing:

 

For example, to store the value 75 in the third element of billy, we could write the

following statement:

 billy[2] =75;

and, for example, to pass the value of the third element of billy to a variable called a,

we could write:

 a =billy[2];

 Therefore, the expression billy[2] is for all purposes like a variable of type int.

Notice that the third element of billy is specified billy[2], since the first one is billy[0],

the second one is billy[1], and therefore, the third one is billy[2]. By this same reason

its last element is billy[4]. Therefore, if we write billy[5], we would be accessing the

sixth element of billy and therefore exceeding the size of the array.

In C++ it is syntactically correct to exceed the valid range of indices for an array. This

can create problems, since accessing out-of-range elements do not cause compilation

errors but can cause runtime errors. The reason why this is allowed will be seen

Page 16: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 16/32

further ahead when we begin to use pointers.

At this point it is important to be able to clearly distinguish between the two uses that

brackets [ ] have related to arrays. They perform two different tasks: one is to specify

the size of arrays when they are declared; and the second one is to specify indices forconcrete array elements. Do not confuse these two possible uses of brackets[ ] with

arrays.

1

2

int billy[5]; // declaration of a new arraybilly[2] = 75; // access to an element of the array.

If you read carefully, you will see that a type specifier always precedes a variable or

array declaration, while it never precedes an access.

Some other valid operations with arrays:

1

2

3

4

billy[0] = a;billy[a] = 75;b = billy [a+2];billy[billy[a]] = billy[2]+ 5;

1

2

3

4

5

6

7

8

9

1011

12

13

14

15

16

// arrays example#include <iostream>using namespace std;

int billy [] = {16, 2, 77, 40, 12071};int n, result=0;

int main (){  for ( n=0 ; n<5 ; n++ ){

result += billy[n];}cout << result;

  return 0;}

12206

Page 17: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 17/32

Multidimensional arrays

Multidimensional arrays can be described as "arrays of arrays". For example, a

bidimensional array can be imagined as a bidimensional table made of elements, all o

them of a same uniform data type.

 

 jimmy represents a bidimensional array of 3 per 5 elements of type int. The way to

declare this array in C++ would be:

  int jimmy [3][5];

and, for example, the way to reference the second element vertically and fourth

horizontally in an expression would be:

 jimmy[1][3]

 

(remember that array indices always begin by zero).

Multidimensional arrays are not limited to two indices (i.e., two dimensions). They can

contain as many indices as needed. But be careful! The amount of memory needed fo

an array rapidly increases with each dimension. For example:

 char century [100][365][24][60][60];

declares an array with a char element for each second in a century, that is more than

3 billion chars. So this declaration would consume more than 3 gigabytes of memory!

Page 18: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 18/32

Multidimensional arrays are just an abstraction for programmers, since we can obtain

the same results with a simple array just by putting a factor between its indices:

1

2

int jimmy [3][5]; // isequivalent toint jimmy [15]; // (3 * 5 =15)

With the only difference that with multidimensional arrays the compiler remembers

the depth of each imaginary dimension for us. Take as example these two pieces of 

code, with both exactly the same result. One uses a bidimensional array and the othe

one uses a simple array:

multidimensional array pseudo-multidimensional array

#define WIDTH 5#define HEIGHT 3

int jimmy [HEIGHT][WIDTH];int n,m;

int main (){for (n=0;n<HEIGHT;n+

+)for

(m=0;m<WIDTH;m++){

jimmy[n][m]=(n+1)*(m+1);

}return 0;

}

#define WIDTH 5#define HEIGHT 3

int jimmy [HEIGHT * WIDTH];int n,m;

int main (){

for (n=0;n<HEIGHT;n++)for (m=0;m<WIDTH;m++){jimmy[n*WIDTH+m]=(n+1)*

(m+1);}return 0;

}

MAIL MERGE

In any working environment, there are situations when a similar type of letter ordocument is to be sent to many persons who reside at different locations. The lettersmay contain the address of each recipient, in addition to the standard informationcontained in the letter. One way of doing this is to print the letters by changing theaddress each time in the document after printing such letter. But this would mean lotof effort and time and also results in bad organisation.

Such problems are taken care of by the Mail Merge facility. In word processing, MailMerge is the process of transferring selected information from one document toanother document.

13.4 CONCEPT OF MAIL MERGING AND ITS COMPONENTS

Page 19: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 19/32

• Mail Merge is the facility which requires the following three information• General body of the letter called main document• Header Row, the record structure or the name of the fields, which will identify

the data

Data for all the individuals, for whom the letters are to be generated also called datasource

Mail Merge option of Word reads this data and physically merges it with Maindocument to generate letters for all the persons or for all records in the data file

PROGRAM DEVELOPMENT LIFE CYCLE

Program Development Life Cycle

 The process of developing a software, according to the desired needs of a user, by

following a basic set of interrelated procedures is known as Program Development Lif

Cycle.

PDLC includes various set of procedures and activitiesthat are isolated and sequence

for learning purposesbut in real life they overlap and are highly interrelated

 Tasks of Program Development

 The basic set of procedures that are followed by various organisations in their program

development methods are as follows:

1.Problem Definition

2.Program Design

3.Coding

4.Debugging

5.Testing

6.Documentation

7.Maintenance8.Extension and Redesign

Page 20: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 20/32

A program may result from some problem, in this case problem means some taskrequiring a solution, or from a bright idea, or because it is a project which has been sefor student. No matter what their first causes computer programs, aka software, andsoftware systems, collections of softwares, have quite well-defined life cycles. Theneed for a program is recognised, the requirements are analysed, a possible solution designed, the prototype is built and tested, and finally the program is put into

use. Figure 1 shows the typical life-cycle fo

a computer program.

During phase one the emphasis is on fact-gathering and determining where theboundaries of the problem are.

Phase two involves the steps of identifyingthe variables and processes which make upthe problem.

Phase 3 is where you will use the tools and

techniques that you learn in this module.During this phase the strategies which will

solve the problem are developed.

Phase 4 represents the time when the solution to the problem, the programs orsystem, is constructed.

Phase 5 is a critical time but can be minimised if the previous steps are correct.

Phase 6, the maintenance phase, is the time when the solution is in active use. It mayundergo enhancements or it may have bugs fixed during its lifetime.

 There is a strong connection between phases 2 and 3 since the process of designing asolution to a problem is an iterative process and often involves a great deal of discovery. For example as you refine an algorithm you might discover that there arevariables and/or processes that weren't obvious during phase 2. This is to be expecteafter all you are just learning about this kind of thing, but you can expect to meet thiskind of discovery right throughout your life as a program designer.

Using Microsoft Word's Menu barFile menu

New - Opens a new document. If you use the keyboard combinatiothe right a blank document opens immediately. Selecting the New with your cursor gives the opportunity to open a large number of tydocuments.

Open - Opens a previously saved document.

Close - Closes the active document but does not quit theapplication.

Save - Saves the active document with its current file name,location and format.

Page 21: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 21/32

Save As - Saves by opening a window which gives the opportunityto change the file name, location or format.

Page Setup - Sets margins, paper size, orientation and other layoutoptions.

Print Preview - Shows how the file will look when you print it.

Print - Prints the active file, also gives the opportunity to changeprint options

Exit - Closes Microsoft Word.

Edit menu

View menu

Insert menu

Format menu

Page 22: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 22/32

Page 23: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 23/32

Help menu

Microsoft Word Help - Open Word's Assistantand get a search box to type in. Word displayspossible matches for you to read about.

Contents and Index - See an index of all topicsavailable in Word's Help documentation.

Microsoft on the Web - That's right! It isexactly what it sounds like. Select a link and aMicrosoft help page is opened in your browser.If you are not online, Word will make the

connection and then display the page.About Microsoft Word - Not sure which versionof Word you working with. Check here forversion information and for the produce IDnumber.

Commonly used keyboard combinations

 To use one of these combinations Hold the Ctrl or Alt key down and strike the letterkey

Ctrl+N Open a new word documentquickly.

Ctrl+X Cut- Removes the selectionfrom the active documentand places it on theclipboard.

Ctrl+O Opens a previouslysaved document.

Ctrl+C Copies the selection to theclipboard

Ctrl+WCloses the active window,but does not Exit Word.

Ctrl+V Paste - Inserts the contentsof the clipboard at theinsertion point (cursor) orwhatever is selected.

Ctrl+S Saves the active document

with its current file name,location and format.

Ctrl+A Selects all text and

graphics in the activewindow.

Ctrl+P Prints the active file, alsogives the opportunity tochange print options

Ctrl+F Find - Searches forspecified text in the activedocument

Alt+F4Exit - Closes Microsoft Word.

Ctrl+B Bold - Formats selectedtext; make text bold, orremove bold formatting

Ctrl+Z Undo the last action. Thisselection can be repeated

Ctrl+I Italic - Formats selectedtext; make text italic or

Page 24: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 24/32

several times. remove italic

Ctrl+Y Redo - After an action hasbeen undone, it can bereinstated in the document.

Ctrl+U Underline - Formatsselected text; make textunderlined or removeunderline

Less commonly used keyboard combinations

Increase selected texttwo points

Apply superscriptformatting

Decrease selectedtext two points

Apply subscriptformatting

Increase selected textone point

Copy formats

Decrease selectedtext one point

Paste formats

Change case of theletters

Single space lines

Underline words butnot spaces

Set 1.5 line spacing

Double underline text Double space lines

Center a paragraphDelete one word to theleft

 Justify a paragraphDelete one word to theright

Left align a paragraph Right align aparagraph

Indent a paragraphfrom the left

Insert a line break

Create a hangingindent

Reduce a hangingindent

If text is already selected and you want to extend the selection area

Extend selection onecharacter to the left

Extend selection onecharacter to the right

Extend selection tothe end of a word

Extend selection to thebeginning of a word

If you want to move the cursor

One character to theright

One character to theleft

One word to the right One word to the left

OPENING AND CLOSING OF DATA FILE IN C

Page 25: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 25/32

Many applications require that information be written or read from an auxiliary storagdevice. Such information is stored on the device in the form of a data file. Thus, a datfile allows us to store information permanently and to access and alter thatinformation whenever necessary. There are two types of data files, one is stream-oriented (or standard) data files and second is system-oriented (or low-level) data file

When working with a stream - oriented data file, the first step to establish a buffer

area, where information is temporarily stored while being transferred betweencomputers memory and the data file. The buffer area is established by writing

FILE * Pointer var;

Where, FILE is a special structure type that establishes the buffer area and pointervariable indicates the beginning of buffer area. The FILE is defined in a, file "stdio.h".A data file must then be opened before it can be created and processed. The libraryfunction 'fopen' is used to open a file. The syntax of fopen is

pintervar = fopen (filename, mode)

where, filename is name of datafile which you wish to open and mode indicates themode in which this file will get open up. The modes in which the user can open a fileare :

Modes Meaning

• "r" Open an existing file for reading only.• "w" Open a new file for writing. If already exist then create new one by deleting

old one.• "a" Open an existing for appending.• ( To append means add at the end).• "r + " Open an existing file both for reading and writing.• "w + " Open a new file both for reading and writing.• "a + " Open an existing file both for reading and appending.

 The fopen function returns a pointer to the beginning of buffer area associated withthe file. A NULL value is returned if the file cannot be opened, for ex., when an existindata file cannot be found.

A data file opened using fopen must be closed at the end of the program. A libraryfunction fclose is used for this purpose. The syntax for fclose is :

fclose (pointervar);

Some applications involved the use of data files to store block of data, where eachblock consist of a fixed number of continuous bytes. Each block will generallyrepresent a complex data structure such as a structure or a array. For suchapplication, it may be desirable to read the entire block from the data file or write theentire block to the data file, rather than reading and writing a individual component.

Page 26: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 26/32

 The library functions fread and fwrite are used for this purpose. These function areoften referred to as unformatted read & write functions. Similarly, data file of this typare referred to as unformatted data file.

In syntax of each of these function requires four arguments:

1) a pointer to a data block,2) the size of data block3) the number of data blocks being transferred and4) the pointer variable attached to the file.

 The syntax for fwrite is :

fwrite(ptr, sizeof (block), no of data blocks, pointerver)

Ex. fwrite(&bank, sizeof (record), 1, fs);

COMPUTER NUMBER SYSTEM

 The binary numeral system, or base-2 number system, represents numeric valuesusing two symbols, 0 and 1. More specifically, the usual base-2system is a positionalnotation with a radix of 2. Owing to its straightforward implementation in digitalelectronic circuitry using logic gates, the binary system is used internally by allmodern computers.

Bits

 The concept of a bit can be understood as a value of 

either 1 or 0, on or off , yes or no, true or false, or encoded by a switch or toggle of 

some kind. A single bit must represent one of twostates:

one-digit binary value: decimal value:----------------------- --------------0 01 1 two distinct values

BytesA byte is often a computer's smallest addressable memory unit. In most computers

this is an ordered sequence of eight bits or binary digits that can represent one of 256

possible values. Most recent computers process information in 8-bit units, or some

other multiple thereof (such as 16, 32, or 64 bits) at a time. A group of 8 bits is now

widely used as a fundamental unit, and is generally called a 'byte' (or

sometimes octet ).

Page 27: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 27/32

[edit]Nibbles

A unit of four bits, or half an octet, is often called a nibble (or nybble). It can encode 1

different values, such as the numbers 0 to 15. Any arbitrary sequence of bits could be

used in principle, but in practice the most common scheme is:

0000 = decimal 00 1000 = decimal 080001 = decimal 01 1001 = decimal 090010 = decimal 02 1010 = decimal 100011 = decimal 03 1011 = decimal 110100 = decimal 04 1100 = decimal 120101 = decimal 05 1101 = decimal 130110 = decimal 06 1110 = decimal 140111 = decimal 07 1111 = decimal 15

 This order (rather than gray code) is used because it is a positional notation, like

the decimal notation that humans are more used to. For example, given the decimalnumber:

7531

is commonly interpreted as:

(7 × 1000) + (5 × 100) + (3 × 10) + (1 × 1)

HIGH LEVEL LANGUAGES

Java

C

Python

Scheme

Prolog

C++

C#

Java script

Lisp

Ruby

LOW LEVEL LANGUAGES

 The "machine language" and "assembly language" for each CPU architecture are thelowest-level programming languages.

 The "Forth language" and the "C programming language" are perhaps the mostpopular non-CPU-specific low-level programming languages. They were onceconsidered high-level programming languages, and certainly they are at a higher levethan assembly language, but now they are considered low-level programminglanguages when compared to the much higher-level languages available today(Python, Java, C++, etc).

Page 28: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 28/32

Low-level programming languages provide little or no abstraction from the CPU'sinstruction set architecture; typically they interact with the hardware directly.

C file fseek() function

 This section demonstrates the use of fseek() function in C. This function sets the fileposition indicator for the stream pointed to by stream or you can say it seeks aspecified place within a file and modify it.

Its syntax is: fseek(FILE *stream, long int offset, int whence)

 The value of whence must be one of the constants SEEK_SET, SEEK_CUR,or SEEK_END, to indicate whether the offset is relative to the beginning of the file, thecurrent file position, or the end of the file, respectively.Now,we will explain you with aexample.In the following code, the function fopen(file, "w") open a file and allow to perform

write operations into the file. The fputs()function writes the string "Hello World" intothe file. Then we have used fseek( f , 6 , SEEK_SET ) function which sets the fileposition indicator to 6 and the fputs() function write the string "India" in place of "World".

Ftell function

<cstdio>

long int ftell ( FILE * stream );

Get current position in stream

Returns the current value of the position indicator of the stream.

For binary streams, the value returned corresponds to the number of bytes from the

beginning of the file.

For text streams, the value is not guaranteed to be the exact number of bytes from

the beginning of the file,

FLOW CHART SYMBOLS

Basic Flowchart Symbols

 The Process Symbol represents any process, function, or

action and is the most frequently used symbol in

flowcharting.

Page 29: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 29/32

 The Document Symbol is used to represent any type of 

hard copy input or output (i.e. reports).

Offpage Connector Symbols are used to indicate the

flowchart continues on another page. Often, the page

number is placed in the shape for easy reference.

 The Input/Output Symbol represents data that is available

for input or resulting from processing (i.e. customer

database records).

Comment Symbols are used when additional explanation

or comment is required. This symbol is usually connected

to the symbol it is explaining by a dashed line.

 The Decision Symbol is a junction where a decision must

be made. A single entry may have any number of 

alternative solutions, but only one can be chosen.

 The Connector Symbol represents the exit to, or entry

from, another part of the same flowchart. It is usually

used to break a flow line that will be continued

elsewhere. It's a good idea to reference page numbers for

easy location of connectors.

COMPILER AND INTERPRETER

A compiler, in general, reads higher level language computer code and converts it toeither p-code or native machine code. An interpreter runs directly from p-code or aninterpreted code such as Basic or Lisp. Typically, compled code runs much faster, ismore compact and has already found all of the syntax errors and many of the illegalreference errors. Interpreted code only finds such errors after the application attemptto interpret the affected code. Interpreted code is often good for simple applicationsthat will only be used once or at most a couple times, or maybe even for prototyping.Compiled code is better for serious applications. A compiler first takes in the entireprogram, checks for errors, compiles it and then executes it. Whereas, an interpreterdoes this line by line, so it takes one line, checks it for errors and then executes it.

A compiler translates the entire program before execution

An interpreter translates one line, executes that line and then• translates the next line

A compiler creates a list of errors after compilation• 

Page 30: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 30/32

An interpreter stops after the first error• 

A compiler produces an independent executable file• 

An interpreted program needs the interpreter each time it is run• 

A compiled program is translated once• 

An interpreted program is translated each time it is run•

DIFFERENT LANGUAGES OF PROGRAMMING LANGUAGES

 There is only one programming language that any computer can actuallyunderstand and execute: its own native binary machine code. This is the lowestpossible level of language in which it is possible to write a computer program. Allother languages are said to be high level or low level according to how closely theycan be said to resemble machine code.

In this context, a low-level language corresponds closely to machine code, so

that a single low-level language instruction translates to a single machine-language instruction. A high-level language instruction typically translates into aseries of machine-language instructions.

Low-level languages have the advantage that they can be written to takeadvantage of any peculiarities in the architecture of the central processing unit(CPU) which is the "brain" of any computer. Thus, a program written in a low-levellanguage can be extremely efficient, making optimum use of both computer

memory and processing time. However, to write a low-level program takes asubstantial amount of time, as well as a clear understanding of the inner workingsof the processor itself. Therefore, low-level programming is typically used only forvery small programs, or for segments of code that are highly critical and must runas efficiently as possible.

High-level languages permit faster development of large programs. The finalprogram as executed by the computer is not as efficient, but the savings inprogrammer time generally far outweigh the inefficiencies of the finished product. This is because the cost of writing a program is nearly constant for each line of code, regardless of the language. Thus, a high-level language where each line of 

code translates to 10 machine instructions costs only one tenth as much inprogram development as a low-level language where each line of code representsonly a single machine instruction.

In addition to the distinction between high-level and low-level languages, there isa further distinction between compiler languages and interpreter languages. Let'stake a look at the various levels.

Page 31: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 31/32

Absolute Machine Code

 The very lowest possible level at which you can program a computer is inits own native machine code, consisting of strings of 1's and 0's and storedas binary numbers. The main problems with using machine code directly arethat it is very easy to make a mistake, and very hard to find it once yourealize the mistake has been made.

Assembly Language

Assembly language is nothing more than a symbolic representation of machine code, which also allows symbolic designation of memory locations. Thus, an instruction to add the contents of a memory location to an internalCPU register called the accumulator might be add a number instead of astring of binary digits (bits).

No matter how close assembly language is to machine code, the computerstill cannot understand it. The assembly-language program must betranslated into machine code by a separate program called an assembler . The assembler program recognizes the character strings that make up thesymbolic names of the various machine operations, and substitutes therequired machine code for each instruction. At the same time, it alsocalculates the required address in memory for each symbolic name of amemory location, and substitutes those addresses for the names. The finalresult is a machine-language program that can run on its own at any time;the assembler and the assembly-language program are no longer needed. Tohelp distinguish between the "before" and "after" versions of the program,the original assembly-language program is also known as the source code,while the final machine-language program is designated the object code.

If an assembly-language program needs to be changed or corrected, it isnecessary to make the changes to the source code and then re-assemble itto create a new object program.

Compiler Language

Compiler languages are the high-level equivalent of assembly language.Each instruction in the compiler language can correspond to many machineinstructions. Once the program has been written, it is translated to theequivalent machine code by a program called a compiler . Once the programhas been compiled, the resulting machine code is saved separately, and canbe run on its own at any time.

As with assembly-language programs, updating or correcting a compiledprogram requires that the original (source) program be modified

Page 32: Computer in Management

8/7/2019 Computer in Management

http://slidepdf.com/reader/full/computer-in-management 32/32

appropriately and then recompiled to form a new machine-language (object)program.

 Typically, the compiled machine code is less efficient than the codeproduced when using assembly language. This means that it runs a bit moreslowly and uses a bit more memory than the equivalent assembled program. To offset this drawback, however, we also have the fact that it takes much

less time to develop a compiler-language program, so it can be ready to gosooner than the assembly-language program.

Interpreter Language

An interpreter language, like a compiler language, is considered to be highlevel. However, it operates in a totally different manner from a compilerlanguage. Rather, the interpreter program resides in memory, and directlyexecutes the high-level program without preliminary translation to machine

code.

 This use of an interpreter program to directly execute the user's programhas both advantages and disadvantages. The primary advantage is that youcan run the program to test its operation, make a few changes, and run itagain directly. There is no need to recompile because no new machine codeis ever produced. This can enormously speed up the development andtesting process.

On the down side, this arrangement requires that both the interpreter andthe user's program reside in memory at the same time. In addition, becausethe interpreter has to scan the user's program one line at a time and executeinternal portions of itself in response, execution of an interpreted program ismuch slower than for a compiled program.