ICT 1B TERM I NOTES
ICT 1B TERM I NOTES
Hardware
Software
Hardware includes all the physical components of the computer such as monitor, mouse,
keyboard etc. Hardware also includes parts inside the system unit, such as motherboard,
processor etc. Processor is a component where all the processing like calculations takes
place.
1. Operating System
2. Application software
3. Programming language
As shown in the diagram below, the Operating System acts as an interface between the
Application and the Hardware. For example: If you want to create a document in an
application- MS-WORD, you will use the hardware devices like mouse and keyboard.
The operating system will interpret your commands and make the application do the
work.
1
Human Users
Hardware
OPERATING SYSTEM
It is system software which acts like an interface between application software and
hardware. It handles all the communication in the computer. Your computer is useless
without operating system. It is installed before installing all other software in your
computer. There are two types of Operating Systems: - GUI and CUI
1. The full form of GUI is Graphic User 1.The full form of CUI is Character
2. The user interacts in GUI by making 2. The user interacts in CUI by making
3. It can be used to run more than one 3. Only one task at a time can be run.
task at a time.
like the mouse for working in GUI as commands from the keyboard, as there
2
ADVANTAGES OF GRAPHICAL USER INTERFACE:
4. Multi-tasking.
APPLICATION SOFTWARE
They help the user to complete tasks such as creating documents, preparing presentations,
accounting etc. They are of two types:
POWERPOINT etc.
Application Softwares are created using different programming languages like C++,
Java, and Visual Basic etc. We will be learning about programming language C++ in the
next chapter.
*************
3
CHAPTER 2. ALGORITHMS AND FLOWCHARTS
What is a program?
2. Implementation Phase
ALGORITHMS
Let us see a day to day example for an algorithm. An algorithm to make tea!
1. Start
5. Add milk
6. Boil again
4
As you can see that certain steps are followed to make tea. These steps are in specific
order.
FLOW CHARTS
Before writing a program in any programming language, we can present the outline of the
program in the pictorial form with some meaningful symbols. This pictorial
representation is called as a flow chart. Flow chart represents actual sequence of steps
in the program using certain standard symbols.
A parallelogram to
Input/Output
represent Input/Output
A rectangle to represent a
Process
process.
A diamond to represent
Decision
decision making.
5
Advantages of drawing flow chart before writing the programs are:
1. Systematic analysis
Example 1: Write an algorithm and draw a flowchart for adding two numbers.
START
1. Start
STOP
START
1. Start
2. Accept a number N .
ACCEPT NUMBER
N 3. Square = N * N.
STOP
6
Example 3: Write an algorithm and draw a flowchart to compute Simple Interest.
START
1. Start
DISPLAY INTEREST
STOP
Assignments:
1. Write an Algorithm and draw a flowchart to accept your name and print it.
3. Write an Algorithm and draw a flowchart to calculate the product of two numbers.
*************
7
CHAPTER 3. INTRODUCTION TO C++
After developing an algorithm and flowchart , now we can start with the implementation
phase. We will use C++ as a programming language for implementing the algorithm.C++
is a programming language which was developed by "Dr. Bjarne Stroustrup”.
LOADING C++
You can start C++ by clicking on the short cut icon “Shortcut to Turbo C++” . C++
automatically opens one program file. It is named as noname00.cpp - cpp stands for C
plus plus.
Your C++ screen indicates the cursor position by displaying the row number and column
number at the left-hand bottom corner of the screen. It also contains the horizontal and
vertical scroll bars and the function key bar.
The program is first developed or written and then executed to get the desired output.
The C++ program is written in the editor screen or C++ editor (blue screen). The
output is shown on a blank screen called as the terminal window.
As you have grammatical rules in English language, there are certain rules in
programming language. These rules have to be followed while using every command in
the programming language. These rules are known as syntax rules. If these syntax rules
are violated, you will get a syntax error on compilation of the program.
1. Typing your Program – Type the program using the proper syntax rules.
2. Saving the Program – Once the program has been typed, it needs to be saved.
This can be done by clicking on File – Save command. C++ automatically saves
the file as a .cpp file. The saved file in C++ is called as the source code.
4. Run –Run means Executing the program to see the output. On execution he output
of your program is seen on the output screen called as TERMINAL WINDOW.
The above steps can be avoided and the output can be directly seen by pressing
ctrl+F9 keys together also.
8
WRITING A C++ PROGRAM
These commands are a must for writing any C++ program. Make sure that you follow
the correct syntax.
Next, you need a heading for your C++ program. Every C++ program has a common
heading, which is as follows:
void main( )
C++ is a case sensitive language. Therefore all commands in C++ are written in
lower case.
The body of the C++ program i.e. the commands of a program also called as a
block, is always enclosed in { } (brace or curly brackets).
For displaying
cout<< console out values/message on the
screen
9
Now, let us write a sample program to display a message “Hello World!” on the
computer.
#include<iostream.h>
#include<conio.h>
void main( )
clrscr( );
As you end every sentence in English with a full-stop, you must end every command in
C++ with a semi-colon.
After you complete the program, you need to execute or run the program. You can
do so by pressing Ctrl + F9 keys on the keyboard.
Hello World!
When you execute the above program, you will notice that the program output is not
visible to you. This is because it gets displayed on the screen and it immediately
vanishes from the screen.
In order to solve this problem, we need a command called getch( ). This command will
keep the output on the screen till we press any key on the keyboard. This command
should be written at the end of the C++ program before closing the brace brackets.
10
Pgup - to move the cursor several lines up
You can use some options while printing the text on the screen. The options are as
follows:
Example:
cout<< “fun”;
cout<< “time”;
funtime
will give the output as: will give the output as:
fun fun
time time
cout<< “fun\t”;
cout<< “time”;
fun time
11
DATA TYPES IN C++
Whenever you use a value in a program, you need to assign it to a variable. Your
command will be as follows:
int a=5;
float x = 12.5;
char ch= ‘a’; note: characters are to be enclosed in single quotation marks.
int a;
a=5;
Hence, 5 = a;
cannot be written and will give a syntax error on compilation of the program.
Sample program for assigning two values and print them on two different lines:
#include<iostream.h> #include<iostream.h>
#include<conio.h> #include<conio.h>
{ OR {
clrscr( ); clrscr( );
12
int a=5; int a,b;
} getch( );
3. After the first letter, variable names can contain digits. No special characters like
4. C++ is case – sensitive. That means uppercase characters are distinct from
5. You cannot use a C++ keyword (reserved word) as a variable name. e.g int,
float,void,cout etc.
Exercise:
1. Write a program to add three numbers and calculate their sum and the average.
2. Write a program to add, subtract, and multiply two numbers. Display the output
with proper messages. The numbers are 50,125.
breadth = 4.5cm.
13
CHAPTER 4. ACCEPTING INPUT IN C++
So far you have been assigning values to the variables within the C++ program. You will
now learn to give values to the variables during program execution.
Here, the user is allowed to give the values to the variables used in the program through
the keyboard. We use cin command for accepting values from the user.
Example: cin>>a;
In case of more than one variable, the cin command will be written as:
Example: cin>>a>>b>>c;
OR
cin>>variable 1;
cin>>variable 2;
cin>>variable 3;
Example: cin>>a;
cin>>b;
cin>>c;
Write a program to accept two float values from the user and find the sum and the
average.
#include<iostream.h>
#include<conio.h>
void main( )
{
clrscr( );
float a,b,s,avg;
cout<< “Enter values for a and b”<<endl; (message prompt to enter values)
cin>>a>>b; (values entered from keyboard will be accepted by the variables)
s=a+b;
avg=s/2;
cout<< “sum=”<<s<<endl;
cout<< “average=”<<avg;
getch( );
}
14
Program output:
14.5 15.6
sum=30.1
average=15.05
Exercise:
1. Write a program to accept three numbers and calculate their sum and
the average.
2. Write a program to accept 2 numbers and add, subtract, and multiply them.
Display the output with proper messages.
3. Write a program to accept two numbers. Calculate and display the quotient and
5. Write a program to accept the currency in dollars and convert it into rupees.
To get the quotient part of division, we use ‘/’ arithmetic operator, and to get the
remainder part of division we use ‘%’ modulo arithmetic operator.
If we need to separate the digits of a two digit number, we need to use both the operators
i.e / and %. To separate the digits, we have to divide the int number by 10.
For example,
int n =56;
After executing the code, we get last digit = 6 and first digit = 5.
15
Exercise:
1. Write a program to accept a number and separate the digits in a 2-digit number
2. Write a program to accept a two digit number. Separate the digits and find the
sum of the digits. For eg: if n=27, then 2+7=9.
3. Write a program to accept a two digit number and check if it is a duck number.
A number is said to be a duck number if it ends with 0.
In the above declaration ‘ch’ is the name of the variable. ‘char’ is the data type used to
declare a character.
#include <iostream.h>
#include <conio.h>
void main( )
{
clrscr( );
char ch;
cout<< “Enter any character:”;
cin>>ch;
cout<<ch<<endl;
cout<<ch<<endl;
cout<<ch<<endl;
cout<<ch<<endl;
getch( );
}
Output of the program
16
A group of characters is called as a String. If you want to store a string, i.e. a word in a
variable, you need to declare the approximate size of that string.
#include <iostream.h>
#include <conio.h>
void main( )
{
clrscr( );
char nm[15];
cout<< “Enter your name”<<endl;
cin>>nm;
cout<< nm<<endl;
cout<< “Welcome to the world of computers”;
getch( );
}
Manju
Manju
**************
17
CHAPTER 5. DECISION MAKING IN C++
In order to make decisions in the program, we make use of the if statement in C++. if
else, if else if are all known as CONDITION STATEMENTS in C++. In order to frame
a condition, we need operators along with the if statement. There are 3 different
types of operators in C++.
TYPES OF OPERATORS
+ Addition a+b
- Subtraction a-b
* Multiplication a*b
/ Division a/b
2. RELATIONAL OPERATORS
These operators establish a relation between two values and decide whether it is true or
false.
== Equal to a= =b
18
Syntax: if(condition)
else
START
The flow chart shows a
simple program outline to
find greater of two numbers.
ACCEPT
A and B
1. Start
2. Accept the values of A and B.
3. If A is greater than B
Print A
Else
Print B
4. End
19
Example: Write a program to input your name and age and check eligibility for
voting.
#include <iostream.h>
#include <conio.h>
void main( )
{
clrscr( );
char nm[25];
int ag;
cout<< “Enter your name”<<endl;
cin>>nm;
cout<< “Enter your age”<<endl;
cin>>ag;
if(ag>=18)
{
cout<<nm<< “You are eligible to vote”;
}
else
{
cout<<nm<< “Sorry you cannot vote”;
}
Exercise:
4. Write a program to accept two numbers from the user and also accept a choice
as 0 or any other number. If the choice is 0, then calculate sum of the two
numbers otherwise product of the two numbers.
*********
20