You are on page 1of 3

ITE 12 Information network

Basic Computer Components LAN - A LAN (Local Area Network) is a system whereby individual
Computer - An electronic device that stores, retrieves, and processes PCs are connected together within a company or organization
data, and can be programmed with instructions. A computer is WAN - A WAN (Wide Area Network) as the name implies allows
composed of hardware and software, and can exist in a variety of you to connect to other computers over a wider area (i.e., the whole
sizes and configurations. world).
Hardware - refers to the physical components of your computer such Uses of Network - If ten people are working together within an office
as the system unit, mouse, keyboard, monitor etc. it makes sense for them all to be connected.
Software - the instructions that makes the computer work. Modem - Short for “MODulate/DEModulate”. The modem sends
information from your computer across the telephone system.
Types of computers
• Mini and Mainframe Computers -Very powerful, used by Uses of Computer
large organizations such a bank to control the entire Computer Based Training (CBT) offers a low-cost solution to
business operation. training needs where you need to train a large amount of people on
• Personal Computers - Cheap and easy to use. Often used a single subject.
as stand-alone computers or in a network. May be Office applications - Stock control, Accounts/Payroll, Automated
connected to large mainframe computers within big production systems, Design systems.
companies.
What are computer viruses? Viruses- are small programs that hide
Hardware Components themselves on your disks (both diskettes and your hard disk).
Input devices - A keyboard and mouse are the standard way to How do viruses infect PCs? - Viruses hide on a disk and when you
interact with the computer. Other devices include joysticks and game access the disk (either a diskette or another hard disk over a network)
pads used primarily for games. the virus program will start and infect your computer.
Output devices - The monitor (the screen) is how the computer sends ___________________________________________________
information back to you. What is a computer
Storage Devices - saves data and programs. Computer is an electronic device that accepts data from the user,
• Hard disk drives are an internal, higher capacity drive processes it, produces results, displays them to the users, and stores
which also stores the operating system which runs when the results for future usage
you power on the computer. Data is a collection of unorganized facts & figures and does not
• "Floppy" disk drives allow you to save work on small provide any further information regarding patterns, context, etc.
disks and take the data with you. Hence data means "unstructured facts and figures".
Memory Information is a structured data i.e., organized meaningful and
• RAM - Random Access Memory, the main 'working' processed data. To process the data and convert into information, a
memory used by the computer. computer is used.
• ROM – Read Only Memory, as the name suggests is a Functions of Computers – Input -> Process -> Store -> Output
special type of memory chip that holds software that can Characteristics of a computer system
be read but not written to. Memory Speed
Automation Accuracy
How Computer Memory Is Measured Reliability Diligence
Versatility
• Bit- All computers work on a binary numbering system,
i.e., they process data in one's or zero's These 1 or 0 levels
Basic Computer System
of storage is called a bit.
Components of a computer System
• Byte- A byte consists of eight bits.
• Kilobyte- A kilobyte (KB) consists of 1024 bytes. Central Processing Unit
• Megabyte-A megabyte (MB) consists of 1024 kilobytes. Control Unit
• Gigabyte- A gigabyte (GB) consists of 1024 megabytes.
Input device Arithmetic/Logic Unit
Microprocessors- "The brain of the computer “. PCs primarily use Output device

microprocessors (sometimes called the chip). The older Intel


versions include the 386, 486 and now the Pentium line. Memory Unit
The CPU (Central Processing Unit) is normally an Intel Pentium (or
equivalent) and it is one of the most important components within
your computer. ALU System - All types of processing, such as comparisons,
• It determines how fast your computer will run and is decision-making and processing of non-numeric information takes
measured by its MHz speed. place here.
• Thus a 600 MHz Pentium is much faster than say a 400 Control Unit - This part of CPU extracts instructions, performs
MHz Pentium CPU. execution, maintains and directs operations of entire system.
Functions of Control Unit
• It controls all activities of computer
Software components • Supervises flow of data within CPU
Operating Systems software- The operating system is a special type • Directs flow of data within CPU
of program that loads automatically when you start your computer. • Transfers data to Arithmetic and Logic Unit
Application software - An application program is the type of • Transfers results to memory
program that you use once the operating system has been loaded. • Fetches results from memory to output devices
Memory unit - This is unit in which data and instructions given to • Syntactically awkward at times (in comparison to
computer as well as results are stored. PASCAL for example)
Computer Programming Languages- any of various languages for • Doesn’t easily support object-oriented programming
expressing a set of detailed instructions for a digital computer. • Not particularly robust compilers and hence not that
Hierarchy of computer language – High level language -> suitable for safety critical applications.
Assembly language -> Machine language -> Computer hardware
PROGRAM
History of C programming language The program starts with the line int main(void) which informs the
C evolved from two previous languages, BCPL and B. BCPL was computer where the program actually starts.
developed in 1967 by Martin Richards. Ken Thompson modeled The int and void are reserved words in C.
many features in his B language. In 1970 Ken Thompson used B to • void indicates that no arguments are passed to the program
create early versions of the UNIX operating system at Bell from the operating system.
Laboratories. The C language was evolved from B by Dennis Ritchie • int indicates that the program returns an integer back to
at Bell the operating system. This allows the program to indicate
Laboratories and was originally implemented on a DEC PDP-11 to the operating system that it has run normally and
computer in 1972. C uses many of the important concepts of BCPL without any errors.
and B while adding data typing and other powerful features. C is The braces {and} signify the beginning and end segments of the
mostly hardware independent program.
The statement #include <stdio.h> is to allow the use of the printf
Program development Cycle – 1. Problem definition, 2. Problem statement. We will say a lot more about this in a future lecture.
analysis, 3. Algorithm development, 4. Coding & documentation, 5. The statement printf(...) is actually a function in C which is used for
Testing and debugging, 6. Maintenance. printing variables and text to the screen.
The text appearing in double quotes “ ” are printed without
Designing an algorithm modification. Exceptions are text following \ and % (modifier)
Algorithm- The solution to any computing problem involves characters which are modifiers.
executing a series of actions in a specific order. A procedure for In our example \n actually means print a new line.
solving a problem in terms of The statement return 0; simply returns a value of zero back to the
1. the actions to be executed, and operating system. Operating systems can interpret return values of
2. the order in which these actions are to be executed. programs to indicate normal behavior or some error condition.
What makes a good algorithm? A final point to note is that all C statements are terminated by a semi-
1. Correctness - A correct algorithm should always give the correct colon ;
solution
2. Efficiency - An efficient algorithm should use minimum resources VARIABLES - In C, variables are used to store values which can
and should perform at an acceptable speed be changed during the course of execution of the program.
How do you measure efficiency?
Placeholder in format Settings
Asymptotic Analysis. Refers to defining the mathematical
Placeholder Variable Type Function use
foundation/framing of its run- time performance
%c Char printf/scanf
Program Control - Specifies the order in which statements are to be
%d Int printf/scanf
executed in a computer program.
%f Double printf
Control Structure- the order in which individual statements,
%lf Double scanf
instructions or function calls of an imperative program are executed
%f Float printf/scanf
or evaluated.
PSUEDOCODE- An artificial and informal language that helps you
Comments - increase the readability and understanding
develop algorithm.
of a piece of code. Comments are text in the program inserted
Sequential- default mode. Sequential execution of code statements
between. /* This is a comment. */
(one line after another)
WHAT ARE COMMENTS USED FOR?
Selection- used for decisions, branching. Choosing between 2 or
• Documentation of variables and their usage
more alternative paths.
• Explaining difficult sections of code
Repetition- used for looping, i.e., repeating a piece of code multiple
times in a row. • Describes the program, author, date, modification
changes, revisions etc.
FLOWCHART - A graphical representation of an algorithm or of a • Copyrighting
portion of an algorithm
WHY C? DATA TYPES
• General purpose int (integer) - These are whole numbers, both positive and negative.
float (floating point) - contain fractional parts both positive and
• Good access to low level input/output
negative.
• Portable
double (double precision) - exponential numbers both positive and
• Supports most commonly used software design techniques
negative.
• Widely used commercially
char (character) - single characters. Ex: letter = ‘A’;
• Provides a good basis for learning C++ and JAVA

OPERATORS
WHY NOT C?
Operation Operator Example 1. Keywords - the collection of pre-defined or reserved words. Ex:
Addition + c=a+b; int, char and auto keywords
Subtraction - c=a-b; 2. Identifiers - informative names that uniquely identify variables or
Multiplication * c=a*b; function names. User-defined words used for naming of functions,
Division / c=a/b; variables, structures, unions, arrays etc.
Increment ++ ++c; • Identifiers shouldn't begin with any numerical digit and
Decrement -- --c; hence, the first character must be either an underscore or
Modulus % c=a%b; an alphabet.
Increment- This adds one to the value of the variable. The increment • Identifiers are case-sensitive and hence, both lowercase
can be applied before (prefix) or after (postfix) the variable is used. and uppercase letters are distinct.
Decrement- This subtracts one from the value of the variable. The • The length of identifiers shouldn't be more than 31
decrement can be applied before (prefix) or after (postfix) the characters.
variable is used. • Commas and blank spaces are not allowed while declaring
Modulus- The modulus operator assigns the remainder left over after an identifier.
a division. Thus, in the following code fragment, the variable count • Also, the most important rule is that we can't use keywords
is assigned to the remainder of dividing 10 by 3 (which is 1). as identifiers because keywords in C language are
Relational operators – if P=5, Q=3, then… reserved words for special purposes only.
Meaning Operator Example 3. Constants - the variables whose values are fixed and cannot be
Equal to == (P==Q) is not modified during the execution of a program once they are defined.
true They are also known as literals. Ex: const
Not equal to != (P!=Q) is true 4. Special Characters - are symbols in C language that have special
Less than < (P<Q) is not true meaning and cannot be used for any other purpose.
Greater than > (P>Q) is true Types of Special Characters:
Less than or equal to <= (P<=Q) is not Square Brackets []- represent single and multi-dimensional
true subscripts and they are used as array element reference for accessing
More than or equal >= (P>=Q) is true array elements.
to Simple Brackets ()- used for function calling and function
declaration.
Conditional Operators - used to evaluate a condition that's applied Curly Braces {}- are used to mark the start and end of a block of
to one or two Boolean expressions. The result of the evaluation is code containing executable logical statements.
either true or false. Comma (,)- used to separate variables or more than one statement
• && the logical AND operator. - is used to perform logical just like separating function parameters in a function call.
conjunction of two expressions (Result: True if both the Pre-Processor / Hash (#)- a macro-processor that is automatically
expressions evaluate to true else the result remains False) used by the compiler and denotes that we are using a header file.
• || the logical OR operator - used to perform logical Asterisk (*)- used for multiplication of variables and also for
disjunction on two expressions (Result: True if either or creating pointer variables.
both the expressions evaluate to true) Colon (:)- used as a part of conditional operator (? :) in C language.
• ?: the ternary operator Semicolon (;)- known as a statement terminator and thus, each
• | not operator - used to perform logical negation on an logical statement of C language must be ended with a semi-colon.
expression Assignment Operator (=)- used to assign values to a variable and
INPUT- allows the programmer to accept input from the keyboard. is sometimes used for logical operation validation.
• takes 2 arguments in the example. The first “%d” specifies 5. Strings- represented as an array of characters having null character
what type of data is expected. The ‘d’ character indicates '\0' at the end. This null character '\0' denotes the end of the string.
that an integer is expected. The size of the string is basically the number of characters it
• The ‘&’ preceding the variable name indicates the address contains. Ex: char name [6] = “Hello”;
6. Operators- special symbols used to perform specific functions,
of the variable.
C provides no error checking of user input. The user is expected to and data items on which they are applied upon are known as
operands.
enter the correct data type.
PREPROCESSOR- is implemented as a first pass over the C
source code, running before the main compilation stage. Performs
following tasks:
• It removes all comments
• It handles the #include statements
• It handles #define commands – these are macro definitions
• #define- preprocessor command is used to make a
program more
LIBRARIES- All C compilers come with a library of useful
functions. The programmer can simply call a library function instead
of having to write the code himself.

TOKENS IN C- the smallest elements or the building blocks used


to construct a C program.
Types of Tokens in C language

You might also like