Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

COM PROG Reviewer

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

What is a computer?

A computer is an electronic data processing


device, which accepts and stores data input, Hardware
processes the data input, and generates the Hardware represents the physical and tangible
output in a required format. components of a computer, i.e., the components
that can be seen and touched.
Functionality of a computer Input devices – keyboard, mouse, etc.
If we look at it in a very broad sense, any digital Output devices – printer, monitor, etc.
computer carries out the following five functions Secondary storage devices – Hard disk, CD, DVD,
- Step 1. Takes data as input. etc.
- Step 2. Stores the data/instructions in its Internal components – CPU, motherboard, RAM,
memory and uses them as required. etc.
- Step 3. Processes the data and converts it
into useful information. Software
- Step 4. Generates the output. Software is a set of programs, which is designed
- Step 5. Controls all the above four steps. to perform a well-defined function.
Applications of Computer  System Software - comprises the programs
1. Business – high speed of calculation you manage
2. Banking – totally dependent  Application Software – comprises the
3. Insurance – keeping all records up-to-date programs you use
4. Education – providing lot of facilities
5. Marketing – advertising and home shopping
6. Healthcare – keep the records of patients Operating System
7. Engineering Design – Computer Aided Design - A program that acts as an interface between
8. Military – largely used in defense the software and the computer hardware.
9. Communication – way to convey message - An integrated set of specialized programs.
10. Government – government services, taxes. - The execution of all other programs

Types of Computers
1. PC (Personal Computer) - single user
computer system having moderately
powerful microprocessor
2. Workstation - a single user computer system,
similar to personal computer however has a
more powerful microprocessor.
3. Minicomputer - a multi-user computer
system, capable of supporting hundreds of
users simultaneously.
4. Main Frame - a multi-user computer system,
capable of supporting hundreds of users A LAYERED
simultaneously. Software technology is VIEW OF
different from minicomputer. THE
5. Supercomputer - an extremely fast
COMPUTER
computer, which can execute hundreds of
millions of instructions per second.
• Qualities of a good algorithm
• Inputs and outputs should be defined
precisely.
• Each step-in algorithm should be clear and
PROGRAM AND PROGRAMMING
unambiguous.
LANGUAGES • Algorithm should be most effective
 Program – is a set of instruction that the among many different ways to solve a
computer follows. problem.
 Programming Language (PL) – is a • An algorithm shouldn’t have computer
standardized communication technique for code. Instead, the algorithm should be
expressing instructions to a computer. written in such a way that, it can be used
 Syntax – set of rules that define the correct in similar programming languages.
structure of statements or expressions.
 Semantics – deals with the meaning or Pseudocode
interpretation of code. • An English-like representation of the logical
 Grammar – structure and composition of steps it takes to solve a problem.
valid statements or expressions • Describes steps of an algorithm in the
“Design” phase
PROGRAM ERRORS • Not a programming language
 Syntax Errors
Flowchart
Errors in grammar of the language
 Runtime error • Flowchart can have only one start and one
Divide by zero and invalid input data stop symbol
 Logical errors • On-page connectors are referenced using
delivers incorrect results and incorrect usage numbers
of parentheses • Off-page connectors are referenced using
alphabets
Programming Development Cycle • General flow of processes is top to bottom or
• It is a model which is used to represent left to right
the stages and tasks that are included • Arrows should not cross each other
orderly in each step to write and put
software.
• It is a set of steps or phases that are
used to develop a program in any
programming language.
1. Problem Definition – define prob. state
2. Problem Analysis – required variables
3. Algorithm Development – stepbystep proced
4. Coding & Documentation – write n implem.
5. Testing & debugging – check the code
6. Maintenance – actively used

Algorithm
An algorithm is the sequence of steps necessary Looping
to solve any programming problem. The repeated use of one or more steps such as
the statement or block of statements.
• Fixed loop where the operations are design of suitable data structures.
repeated a fixed number of times. • Data abstraction – general and
• Variable loop, the operations are repeated representations in particular.
until a specific condition is met. • Object-oriented programming – use of
class hierarchies.
C++ Basics
• Generic programming – an algorithm can
• C++ is a statically typed, compiled, be designed to accept a wide variety of
general-purpose, case-sensitive, free- types as long as they meet the
form programming language that algorithm’s requirements on its
supports procedural, object-oriented, and arguments.
generic programming.
• C++ is regarded as a middle-level Using IDE
language, as it comprises a combination An Integrated Development Environment
of both high-level and low-level language (IDE) is an application used to write,
features. compile, and execute C/C++ programs
• C++ was developed by Bjarne Stroustrup STEPS FOR C++ PROGRAM DEVT AND
starting in 1979 at Bell Labs in Murray EXECUTION:
Hill, New Jersey, as an enhancement to • Editing
the C language and originally named C • Compiling
• Linking Library Files
with Classes but later it was renamed C++
• Loading
in 1983.
• Execution
• C++ is a superset of C, and that virtually
any legal C program is a legal C++
Parts of Coding C++
program.

Basic Input / Output in C++


• Input Stream: If the direction of flow of bytes
is from the device to the main memory, then
this process is called input.
• Output Stream: If the direction of flow of
bytes is opposite, i.e., from main memory to
device then this process is called output.
Programming Style
Header files:
The C++ language features most directly support • iostream: stands for standard input-output
four programming styles: stream. This header file contains definitions
• Procedural programming – this is of objects like cin, cout, cerr, etc.
programming focused on processing and the • iomanip: stands for input-output
manipulators. The methods declared in these
files are used for manipulating streams. This
file contains definitions of setw, setprecision,
etc.
• fstream: This header file mainly describes the
file stream. This header file is used to handle
the data being read from a file as input or Formatting the output in C++
data being written into the file as output.
- width(): The width method is used to set
the required field width. The output will be
To include cin and cout:
• Standard output stream (cout): (<<) displayed in the given width
The C++ cout statement is the instance of the - precision(): The precision method is used to
ostream class. It is used to produce output on set the number of the decimal point to a
the standard output device which is usually float value
the display screen. - fill(): The fill method is used to set a
• Standard input stream (cin): character to fill in the blank space of a field
C++ cin statement is the instance of the class
- setf(): The setf method is used to set
istream and is used to read input from the
standard input device which is usually a various flags for formatting output
keyboard. - unsetf(): The unsetf method is used To
• The extraction operator (>>) is used along remove the flag setting
with the object cin for reading inputs. The
extraction operator extracts the data from Function getline and cin
the object cin which is entered using the - cin is an instance of istream class. The
keyboard. object is related to the standard input
device (keyboard). It works with the stream
Data Types extraction operator which is >>.
• char (one letter) - The C++ getline() is an in-built function
• string (sentence, phrases) defined in the <string.h> header file that
• boolean (true or Flase) allows accepting and reading single and
• int (whole number) multiple line strings from the input stream.
• float (precise less decimal) In C++, the cin object also allows input from
• double (precise more decimal) the user, but not multi-word or multi-line
input. That’s where the getline() function
Escape Sequences comes in handy.
- are special non-printing characters that Expression
are used to control the printing behavior - An expression in C++ is an order
of the output stream objects (such as
collection of operators and operands
‘cout’).
- The backslash (“\”) is called an escape which specifies a computation.
character ex.
b = 25 + a, a / (b + c), x = 6.75 * 2, x ==
2.6. etc.
Categories of Expression in C++
Constant expressions
- Constant expressions contain only
constant values in an expression. Assignment Operator
Ex. x=25+10 i=(10/2) + 5 - In C++, assignment operators are used
to assign values to variables
Integral expressions ex : // assign 5 to a
- Integral expressions that result in an a = 5;
integral value after evaluating an Arithmetic Operators
expression. - Arithmetic operators are used to
Ex. x + int(12.0) (i * j) -10 perform arithmetic operations on
Float expressions variables and data.
- Float expressions that result from float
values after evaluating an expression.
Ex. i+j (i/14) + j 87.3 i+float(14)
Pointer expressions
- pointer expression which results in an
address of a variable after evaluating an
expression.
Ex. &i ptr ptr++ ptr-
Relational expressions
- Relation expression which results from
a bool value either true or false after
evaluating an expression. Increment and decrement (++, --) Operator
Ex. i<b i-b <= a-b i+b>100 a*2>b - If you use the ++ operator as a prefix like: +
Logical expressions +var, the value of var is incremented by 1;
- Logical expression which results in a then it returns the value.
bool value either true or false after - If you use the ++ operator as a postfix like:
var++, the original value of var is returned
evaluation a combination of two or
first; then var is incremented by 1.
more relational expressions.
- The -- operator works in a similar way to the
Ex. I<j && X>Y i>10 || j==5 (a<b)&&(b<c)
++ operator except -- decreases the value
Bitwise expressions by 1.
- Bitwise expressions perform the Relational Operators
operation at a bit level in an expression. - These operators are used for the
Ex. a&2 a|2 a>>2 comparison of the values of two operands.
- The result returns a Boolean value, i.e., true
Operators or false.
- an operator is a symbol that tells the
compiler to perform specific
mathematical or logical manipulations.
Logical Operators
- Logical operators are used to check whether
an expression is true or false.

You might also like