0% found this document useful (0 votes)
13 views109 pages

Computer Full Notes Completed 10 Classs

computer notes

Uploaded by

Aisha Siddiqa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views109 pages

Computer Full Notes Completed 10 Classs

computer notes

Uploaded by

Aisha Siddiqa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 109

Islamabad Career Schools- Network Computer Notes - X

Exercise Short Questions

Chapter#1
1. Define computer.

A device which process data and convert it into information is

Called computer.

OR

Computer is a general-purpose programmable machine that has ability


to store, retrieve and process data that is represented in the form of 0s
and 1s.

2. What is algorithm and what is the role of algorithm in problem


solving?

Algorithm

Algorithm is a step by step procedure developed to solve a problem


before writing an actual program.

OR

It is a set of steps that clearly defines a sequence of operations to solve


a problem.

Role of Algorithm

Algorithm plays an important role in problem solving such as computer


programming. Computer programming is the process of taking an
algorithm and coding it in a programming language.

1
Islamabad Career Schools- Network Computer Notes - X

2
Islamabad Career Schools- Network Computer Notes - X

3
Islamabad Career Schools- Network Computer Notes - X

3. What is Flowchart?

Flowchart is a diagrammatic representation of algorithm. It describes


what operation is required to solve a given problem.

OR

Pictorial representation of an algorithm is known as flowchart.

4
Islamabad Career Schools- Network Computer Notes - X

4. Write advantages of flowchart.

1. Flowchart describes the sequence of operations to be performed to


solve a problem in the form of diagram.

2. Computer programmers draw flowcharts before writing computer


programs.

3. Flowchart provides an easy way to analyze and solutions of problems

4. Flowchart is very helpful in communicating the problem solving


method to other people.

5. Flowchart helps in finding and removing errors in computer


programs.

5. Draw any four symbols used in flowchart and explain them.

Symbols shape Symbol name purpose


Flow line It is used to show the flow of
direction, joins symbols with each
other in flowchart.
Terminal It is used to start and stop/end of a
flowchart.
Rectangle It is used for processing in a
flowchart.
parallelogram This symbol represents input or
output operations in a flowchart.

5
Islamabad Career Schools- Network Computer Notes - X

Extensive Questions:

1. Write an algorithm to calculate the area of a rectangle for a given


breadth and length.

Step 1: Start

Step 2: Input width (w) and length (L) of rectangle.

Step 3: Area=Length*Width A=L*W

Step 4: Print Area (A)

Step 5: End

2. Write an algorithm that inputs length in inches and calculate, print in


centimeters.

Step 1: Start

Step 2: Input length in inches (LI)

Step 3: Calculate length in cm

OR

Step 3: L cm=Li*2.54

Step 4: print L cm

Step 5: End

6
Islamabad Career Schools- Network Computer Notes - X

3. Write an algorithm that inputs marks and prints massage pass or fail.
passing marks are 33.

Step 1: Start

Step 2: Input Marks(M)

Step 3: Check if (M<33) then print Fail Goto step 5

Step 4: Else Print Pass

Step 5: End

4. Write an algorithm to find sum of given sequence.

Sum=20+25+30+35+40+45+50+55+60

Step 1: Start

Step 2: Sum=0,K=5

Step 3: Sum=Sum +k

Step 4: K=k=5

Step 5 If k≤100 Then Goto Step3 otherwise Goto Step6

Step 6: Print Sum

Step 7: End

5. Write an algorithm to find product of given number.

Product= 1*3*5*7*9*11*13*15

Step 1: Start

7
Islamabad Career Schools- Network Computer Notes - X

Step 2: k=1, prod=1

Step 3: K=k+2

Step 4: Prod=Prod*k

Step 5: If k≤16 Then Goto Step3 otherwise Goto step6

Step 6: Print Prod

Step 7: End

6. Write an algorithm to print multiplication table of a number in


reverse order.

Step1: Start

Step 2: Enter Number N

Step 3: I=10

Step 4: Prod=N*1

Step 5: Print N, I and Prod

Step 6: I=i-1

Step 7: If the value of I is >0 Then Goto step 4 otherwise Goto step 8

Step 8: End

8
Islamabad Career Schools- Network Computer Notes - X

FLOWCHARTS
start

INPUT L, B

AREA=L*B

PRINT AREA

END

FLOWCHARTS NO 5
start

INPUT LENGTH LI

LCM=LI*2.54

PRINT LCM

END

9
Islamabad Career Schools- Network Computer Notes - X

FLOWCHARTS NO 6

START

INPUT MARKS(M)

YES
IF M<33
NO
FAIL

PASS

STOP

10
Islamabad Career Schools- Network Computer Notes - X

FLOWCHARTS NO 7

START

SUM=0,K=5

SUM=SUM+K

K =K+5

YES

NO
IF K<60

PRINT SUM

END

11
Islamabad Career Schools- Network Computer Notes - X

FLOWCHARTS NO 8

START

K=1,PROD=1

K=K+2

PROD=PROD*K

NO YES

IF K<16

PRINT PROD

END

12
Islamabad Career Schools- Network Computer Notes - X

FLOWCHARTS NO 9

START

ENTER NUMBER N

I=10

PROD=N*1

PRINT N,I,PROD

I=I-1

YES NO

IF I>0

END

CHAPTER 2

13
Islamabad Career Schools- Network Computer Notes - X

EXERCISE SHORT QUESTIONS

1. Define computer programming.

Computer programming is the process of writing a computer program


in computer language to solve a particular problem.

Computer program controls the operation of computer and it is


developed in a computer language to perform a task .computer
language are also known as programming languages.

2. Define computer program.

14
Islamabad Career Schools- Network Computer Notes - X

A computer program is a set of instructions written in programming


language to solve a particular problem and achieving specific results.

A large variety of programming language have been developed for


writing computer programs to use the computer as a problem solving
tool.

3. Difference b/w syntax and semantic.


SYNTAX SEMANTIC
1. Syntax refers to the rule of 1. Sementic gives meaning to
programming language. statement of a programming language.
2. It describes the way to write correct 2. It describe the sequence of
statement in a program. operation to be performed by a
computer.
3.Example variable=expression 3.Example sum=a+ b;

4. Write three differences b/w assembly language and Hlls.

HIGH LEVEL LANGUAGE ASSEMBLY LANGUAGE

15
Islamabad Career Schools- Network Computer Notes - X

1. Hll are easily understandable. 1. Assembly language are difficult to


understand.
2. The programs that are developed in 2. The programs that are developed in
high level language are portable. assembly language are not portable.
3. The programs developed in high level 3. The programs developed in assembly
languages are not machine dependent. languages are thoroughly machine
dependent.

5. Define IDE.

16
Islamabad Career Schools- Network Computer Notes - X

IDE stands for integrated development environment.it is a computer


software that brings all the process and tool required for program
development into one place .Ide,s aim is to make the life of
programmers easier by grouping together all the tasks needed for
building applications in to one environment.

6. Difference b/w constant and variable.

CONSTANT VARIABLE

17
Islamabad Career Schools- Network Computer Notes - X

1. Constant are quantities whose values 1. Variable is a symbolic name that


do not change during program represents a value that can be change
execution. during program execution.
2.Types of constant, i Numeric ii String 2.Types of variable, i Numeric ii String
3.Examples 174,39.5,”14th Aug 1947” 3. Examples x55,b2,b33$,grade$.

7. which of following are valid c variable.

Valid My_ weight, Area,Size22,Sum

Not Valid

5X A variable cannot be start with number.


Net pay Space cannot be used as a variable name.
Float Data types cannot be used as a variable name.
_age Special character (_) cannot be used in variable name.
Else Commands cannot be used as variable name.
Case Commands cannot be used as variable name.

9.What are reserved words? why they should not be used as variable
names?

The words that are part of programming language and have special
purposes in computer programs are called reserved words or keywords.

Reserved words have predefined meaning and predefined uses and


cannot be used for any other purposes.

10. Why comments are used in programs.

1. It is good programming practice to add in program to make it easy


for others.

18
Islamabad Career Schools- Network Computer Notes - X

2. Comments are source code are ignored by the compiler.


3. Comments are added in programs when a fact is necessary to be
brought to the attention of program,s readers.
4. Generally programmers write comments at beginning of the
program explaining the reader what the program is intended to
achieve and inside the program code.

11. What is the use of typecasting in c programs.

Typecasting is a method to convert a variable from one data type to


another data type during program execution.

Example
A variable of type int can act as a variable of type char using
typecasting. This is required in some situations in programming in c
language

Compiler Interpreter
A compiler is a program that An interpreter is a program that translates high
translates source program into level language programs into machine language
object program. but one line at a time.
It translates whole program. It translates one line at a time.
Example C, pascal, java etc Example Basic, VB,Perl etc
12. Difference b/w Assembler and Interpreter
Source program Compiler Object program

19
Islamabad Career Schools- Network Computer Notes - X

C # Features

C# is object oriented programming language. It provides


a lot of features that are given below.

Simple

1. Modern programming language


2. Object oriented
3. Type safe
4. Interoperability
5. Scalable and Updateable
6. Component oriented
7. Structured programming language
8. Rich Library
9. Fast speed

20
Islamabad Career Schools- Network Computer Notes - X

CHAPTER 3:

21
Islamabad Career Schools- Network Computer Notes - X

Exercise Short Questions.


1 Why format specifier is used? explain with example.
Format specifiers:
A format specifier is computer code that tells about data type,field
width and format according to which a value to be printed or read
from an input device.A list of commonly used format specifiers is given
below.

%d decimal integer
%i integer
%ld long decimal integer
%f floating point(decimal notation)
%g floating point(exponential(notation)
%e floating point (%f or %g,whichever is shorter)
%c single character
%s string

2.Why escape sequence is used? explain with example

The special characters used in c language to control printing on the


output device are called escape sequence. These characters are not
printed.these are used inside the control string.
An escape sequence is a combination of a backslash (\) and a code
character.the backslash is called control character.
\a=produce alert sound,\b=move cursor backward,\?=produce question
mark etc.

Example

# include<stdio.h>

Void main(void)

22
Islamabad Career Schools- Network Computer Notes - X

Printf(“\nrings bell three times.\a\a\a*);

Printf(“\nremoves 2 space between name.sajjad \b\bhaider”);

Priintf(“\ndisplays question mark at end.who ara you\?*);

Getch();

Output of a program

Rings bell three times.


Removes 2 spaces the name.Sajjad haider
Display question mark at end.who are you?

3.what is the purpose of gets() function with an example.

The gets() function is used to read a string from the keyboard and store
it in the variable specified inside the parenthesis.

Example

#include<stdio.h>

Void main(void)

23
Islamabad Career Schools- Network Computer Notes - X

Char name [20];

Printf(“\nEnter your name:”);

Gets(name);

Printf(“\nMy name is %s”,name);

getch() ;

Output of a program

Enter your name: Sajjad haider


My name is Sajjad haider

5. Difference b/w getch() and getche() functions.

Getch() Function Getche() Function


It does not display type character to It display single character on the screen
the screen. without using enter key.
It is the compulsory part of every It is not the compulsory part of every
program. program.

Example

#include<stdio.h>

24
Islamabad Career Schools- Network Computer Notes - X

#include<conio.h>

Void main(void)

Char ch;

Printf(“\nEnter a single character:”);

Ch=getche();

Printf(“\nThe character you typed is %s”,ch);

Getch();

Output of a program

Enter a single character :p


The character you typed is q

25
Islamabad Career Schools- Network Computer Notes - X

5.Evaluate following expressions.

a) 7+5*(3+4) b) 100/10/4 c) 50%13%3 d) 30/7*3-6

a) 7+5*(3+4)

Solution

7+5*(3+4)

=7+5*7

=7+35

=42

b) 100/10/4

Solution

100/10/4

=10/4

=2.5

c) 50%13%3

Solution

50%13%3

=11%3

=2

26
Islamabad Career Schools- Network Computer Notes - X

d) 30/7*3-6

solution

30/7*3-6

=4.28*3-6

=12.8-6

=6.8

6.what will be the output of question no 6 from exercise?

Output

Z1=3

Z2=2

Z3=18

Z4=5

7.What will be the output of question 7 from exercise?

Output

C=7.840000

D=2.120000

E=6.160000

F=10.920000

27
Islamabad Career Schools- Network Computer Notes - X

Exercise programs.

Question 1.

#include<stdio.h>

Int main()

Int num1,num2,num3,sum,prod,avg;

Printf(“Enter the three numbers separated by’,’\n”);

Scanf(“%d,%d,%d”,&num1,num2,num3);

Sum=num1+num2+num3;

Prod=num1*num2*num3;

Avg=sum/3;

Printf(“the sum of three numbers is:%d\n”,sum);

Printf(“the prod of three numbers is:%d\n”,prod);

Printf(“the average of three numbers is:%d\n”,avg);

28
Islamabad Career Schools- Network Computer Notes - X

Question 2.

#include<stdio.h>

main()

Float length,width,area;

Printf(“Enter length of rectangle”);

Printf(“Enter width of rectangle”);

Scanf(“%f”,& width);

Area=length*width;

Printf(“area of rectangle=%f sq.units”,area);

Question 3.

#include<stdio.h>

.#include<conio.h>

main()

29
Islamabad Career Schools- Network Computer Notes - X

Float side,volume

Printf(“Enter length of any side of cube\n”);

Scanf(“%f,&side);

Volume=side*side*side;

Printf(“volume of cube: %0.4\n”,volume);

Question 4.

#include<stdio.h>

.#include<conio.h>

main()

Float fhren,Celsius;

Printf(“enter the temperature in Celsius\n”);

Scanf(“f”,&Celsius);

Fahren =(9.0/5.0)*Celsius+32;

Printf(“%.2fc is equal to %.2fF\n”,Celsius,fahren);

30
Islamabad Career Schools- Network Computer Notes - X

Question 5.

#include<stdio.h>

#include<string.h>

Int main()

Char name[50],add[50];

Printf(enter your name:”);

gets(name);

Printf(enter your address:”);

gets(add);

Printf(Your name is:”);

Puts(name);

Printf(“your address is:”);

Puts(add);

31
Islamabad Career Schools- Network Computer Notes - X

CHAPTER 4:

Exercise short Questions.

1. Difference b/w if and if else selection structures.

IF selection structure IF-else selection structure

If statement is a control statement. when It is a conditional statement. if else


if statement is executed the condition statement is used in situation where
inside brackets is evaluated. some code is to be executed.

If condition is true then two statements If condition is true then block of


following the keyword if are executed. statement following if will be
executed and block of statement
following else will be skipped.

If condition is false then following two If condition is false then block of


statement will be skipped and program statement following if will be skipped
will terminate and there will be no output. and block of statement following else
will be executed.

Syntax Syntax

If(condition) If(condition)

{ {

32
Islamabad Career Schools- Network Computer Notes - X

Block of statements Block of statements

} }

Else

Block of statements

2.Difference b/w else-if and switch selection structure.

Else-if selection structure Switch Selection structure

The else-if statement is used in situation The switch statement is smiller to


where some code is to be executed if a else-if statement but it is used in
condition is true and some other code is multiple choices are given and one
to be executed if condtion is false. choice is to be selected.

Syntax Syntax
Switch(expression) If(condition)
{ {
Case const-1: Block of statements
Statements; }
Break; Else

33
Islamabad Career Schools- Network Computer Notes - X

Case const-2: {
Statements; Block of statements
Break; }
.
.
Default:
Statements;
}

3. What is nested selection structure? or nested loop.

The selection structure that is within another selection structure is


known as nested selection structure.

OR
The loop inside one or more loop is called nested loop.
In computer programming it is required to use a selection structure
within another selection structure. This is also supported in c language.
In c language ,the programmer can have a selection structure(If,if-else,
else if or switch statement) within another selection structure.

4.Write following statement using if-else statement.


K=(a+b>20)?a+3*:a-b;=
Ans

34
Islamabad Career Schools- Network Computer Notes - X

If(a+b)>20
K=a+3*b;
Else
K=a-b;

5.Write following statement using conditional operator.


If(x>y)
Z=(x=y)/3;
Else

Z=x-5*y;

Ans

Z=(x>y)?(x+y)/3:x-5*y;

6.What will be output of the following code of question no 6?

Ans

Count=10

Sum=58

7.What will be output of the following code of question no 7?

Ans Good bye!

35
Islamabad Career Schools- Network Computer Notes - X

Chapter 5
Exercise short questions.

1.Difference b/w For loop and While loop.

FOR LOOP WHILE LOOP

The for loop is used to execute a set of The while loop is used to to execute a
statement repeatedly for a fixed set of statement or keep repetitions
number of times. continues until some condition
remains true.

In For loop the programmers known in In While loop the programmers is not
advance to how many times loops must known in advance to how many times
be repeated. loops must be repeated.

Syntax Syntax

For(initialization;test While (test condition)


condition;increment/decrement)
{
{
Body of loop
Body of loop
}
}

36
Islamabad Career Schools- Network Computer Notes - X

2.Difference b/w While and Do while loop with example

While () Loop Do while () Loop

While() loop is pre-tested loop. Do while loop is post-tested loop.

In ̔ while’ loop the controlling In ̔do-while’ loop the controlling


condition appears at the start of condition appears at the end of
loop. the loop.

The iterations do not occur if the The iteration occurs at least once
condition at the first iteration, even if the condition is false at
appears false. the first iteration.

Syntax Syntax

While(condition) Do

{ {

Statement; // body of loop Body of the loop

} }

While(test condition);

37
Islamabad Career Schools- Network Computer Notes - X

3.What will be the output of question no 3?

Ans

I am a student

I am a student

I am a student

I am a student

I am a student

GOOD BYE

4.What will be the output of question no 4?


Ans
30
25
20
15
10

5.Find errors in the following code.

Int k,a

a=3;

38
Islamabad Career Schools- Network Computer Notes - X

K=1 ;

While (k<10);

Print(“\n%f\t%f”,k,k*a-1);

K=k+2;

Ans

int a,k;

a=3;

k=1;

while(k<10)

Printf(“\n%d\t%d”,k,k*a-1);

K=k+2;
}
Output:
1 2
3 8

39
Islamabad Career Schools- Network Computer Notes - X

5 14
7 20
9 26
6.Convert following for loop into a while loop.
Int k;
For(k=25; k>0; k=k-3)
Printf(“\n%d”,k);
Ans
Int k;
k=25
while(k>0)
{
Printf(“\n%d” ,k);
K=k-3
}

40
Islamabad Career Schools- Network Computer Notes - X

CHAPTER 6

Short Questions

1. what is a logic gate?

Logic gates are the basic building blocks of digital computer.

Logic gates operate on two voltage levels and process digital signals
which represents binary digital 0 and 1.

2.Define truth table.

A truth table represents a digital logic circuit in table form.

41
Islamabad Career Schools- Network Computer Notes - X

It shows how a logic circuits output represents to all the possible


combinations of the inputs using logic ‘1’ for true and logic ‘0’ for
false.

3.Define Boolean function.

A Boolean function can be transformed from an algebraic expression


into a logic circuit composed of AND,OR ant NOT gates.

A Boolean function is an expression formed with binary variables,


the logical operators(OR,AND,NOT)parenthesis and equal sign. A
binary variables can take the value of 0 and 1.

Example

F=x+y

If x=0 and y=0 the result=0

For all the other combination of x and y, the function will be=1

42
Islamabad Career Schools- Network Computer Notes - X

4.What is k-Map and why is it used?

K stands for Karnaugh.k-map is a pictorial form of truth table. It consist


of square boxes called cells. All the possible combinations of variables
involved in Boolean function are written inside the cells in their
positions.

A two-variable k-map contains 22 =4 cells

22 =4

Fomat of 3-variable k-map 23=8

43
Islamabad Career Schools- Network Computer Notes - X

Use of K-Map

k-map is used for logic simplification. A k-map provides a pictorial


method of grouping together expression with common factors and
therefore eliminating unwanted variables.

44
Islamabad Career Schools- Network Computer Notes - X

45
Islamabad Career Schools- Network Computer Notes - X

46
Islamabad Career Schools- Network Computer Notes - X

5.Draw three –variables K-map for variables A,B and C.

B B B B

A B C A B C A B C A B C
A
A B C A B C A B C
A A B C
C C C C

6.Wite down rules of simplifying a three variable k-map.

1. For each term of the function. place 1 in the corresponding cell in


k=map
2. From groups of four if possible otherwise group of two.
3. Groups can contain only 1s.
4. Groups can be horizontal or vertical.
5. Groups can overlap and wrap around the side of k-map.
6. If possible include each 1 in at least one group.
7. Eliminate the variable that are in normal and complemented form
in a group and create a term for each group.

47
Islamabad Career Schools- Network Computer Notes - X

8. Write the simplified function in the form of sum of terms. if a cell


contain a 1 cannot be included in any group then write full term
with three variables.

Long Question

Draw the graphical symbols of AND,OR,NOT gates and with their


diagram/circuits functions.

AND Gate:
The logic gate AND takes two or more input and works as per the
following truth table

48
Islamabad Career Schools- Network Computer Notes - X

49
Islamabad Career Schools- Network Computer Notes - X

OR Gate:
The logic gate OR takes two or more input and works as per the
following truth table

50
Islamabad Career Schools- Network Computer Notes - X

51
Islamabad Career Schools- Network Computer Notes - X

52
Islamabad Career Schools- Network Computer Notes - X

NOT Logic Gate:


The logic gate NOT takes only one input and works as per the following
truth table.

53
Islamabad Career Schools- Network Computer Notes - X

Symbols and diagram of different logic gates.

54
Islamabad Career Schools- Network Computer Notes - X

1.Draw graphical symbols of AND,OR,NOT.NAND and NOR gates and


write their functions.

Basic Logic Gates:

There are three basic logic gates are used in digital circuits which are
AND,OR and NOT gates.

AND Gate:

The AND gate has two or more inputs that can be LOW(0) or HIGH(1).

the output is high only when all the inputs are high. it produces a low
output when at least one of the inputs is low

55
Islamabad Career Schools- Network Computer Notes - X

OR GATE:

NOT GATE

56
Islamabad Career Schools- Network Computer Notes - X

NAND GATE:

NOR GATE:

57
Islamabad Career Schools- Network Computer Notes - X

Explain how NAND and NOR gates can be created using AND,OR and
NOT gates.

1.Creating NAND gate using basic gates.

A F=AB F=AB

58
Islamabad Career Schools- Network Computer Notes - X

F=A+B F=A+B

2.Creating NOR gate using basic gates.

Draw truth table of the following functions.


1.F1=xyz+xyz+xyz
2.F2=xz+yz+xyz
3.F3=xyz+xyz+xyz+xyz
4.F4=xz+xy

Soiution

1.F1=xyz+xyz+xyz

59
Islamabad Career Schools- Network Computer Notes - X

x y z x y z xyz xyz xyz F1


1 1 1 0 0 0 0 0 0 0
1 1 0 0 0 1 0 0 1 1
1 0 1 0 1 0 0 0 0 0
1 0 0 0 1 1 0 0 0 0
0 1 1 1 0 0 0 1 0 1
0 1 0 1 0 1 1 0 0 1
0 0 1 1 1 0 0 0 0 0
0 0 0 1 1 1 0 0 0 0

2.F2=xz+yz+xyz
x y z x y z xz yz xyz F2
1 1 1 0 0 0 0 0 1 1
1 1 0 0 0 1 0 1 0 1
1 0 1 0 1 0 0 0 0 0
1 0 0 0 1 1 0 0 0 0
0 1 1 1 0 0 1 0 0 1
0 1 0 1 0 1 0 1 0 1
0 0 1 1 1 0 1 0 0 1
3.F3=xyz+xyz+xyz+xyz

X Y Z X Y Z Xyz Xyz xyz xyz F3

60
Islamabad Career Schools- Network Computer Notes - X

1 1 1 0 0 0 0 0 0 0 0

1 1 0 0 0 1 0 0 0 1 1

1 0 1 0 1 0 0 0 0 0 0

1 0 0 0 1 1 0 0 0 0 0

0 1 1 1 0 0 0 0 1 0 1

0 1 0 1 0 1 0 0 0 0 0

0 0 1 1 1 0 0 1 0 0 1

0 0 0 1 1 1 1 0 0 0 1

61
Islamabad Career Schools- Network Computer Notes - X

4.F4=xz+xy

X Y Z X Y Z xz xy F4

1 1 1 0 0 0 0 0 0

1 1 0 0 0 1 1 0 1

1 0 1 0 1 0 0 0 0

1 0 0 0 1 1 1 0 1

0 1 1 1 0 0 0 0 0

62
Islamabad Career Schools- Network Computer Notes - X

0 1 0 1 0 1 0 0 0

0 0 1 1 1 0 0 1 1

0 0 0 1 1 1 0 1 1

Simplify the Boolean Functions of Question 5 using K-map.

1.F1=xyz+xyz+xyz
Step#1

YZ YZ YZ YZ

Xy z xyz xyz xyz


X
xyz xyz xyz xyz
X

63
Islamabad Career Schools- Network Computer Notes - X

Step#2
YZ YZ YZ YZ
0 0 1 1
X
X

Step# 3

Grouping 0 0 0 1
Group#1 xy z, x y z = xy
Group#2 xy z, x y z = yz
Step#4
Apply Maxterm function
Xy+yz

Simplify the Boolean Functions of Question 5 using K-map.

2.F2=xz+yz+xyz x+x=1
y+ y=1
Z+Z=1

First of all complete the variable


Step#1 xz+yz+xyz
Xz(1)+(1)yz+xyz
Xz(y+ y)+( x+x)yz+xyz
Xyz+xyz+xyz+xyz+xyz

YZ YZ YZ YZ

64
Islamabad Career Schools- Network Computer Notes - X

xyz xyz xyz Xyz


X
xyz xyz xyz Xyz
X

Step#2
YZ YZ YZ YZ
0 1 1 1
X
X

0 0 1 1
Step# 3
Grouping
Group#1 xy z, x y z = xz
Group#2 xy z, x y z = yz
Group#3 xy z, x y z = yz

Step#4
Apply Maxterm function
Xz+yz+yz
Ans Xz+y

Simplify the Boolean Functions of Question 5 using K-map.

3.F3=xyz+xyz+xyz+xyz

Step#1

65
Islamabad Career Schools- Network Computer Notes - X

YZ YZ YZ YZ

Xy z xyz xyz Xyz


X
xyz xyz xyz Xyz
X

Step#2
YZ YZ YZ YZ
1 1 1 0
X
X

Step# 3

Grouping 0 0 0 1
Group#1 xy z, x y z, x y z
missing(xyz)
Group# xy , x, x z,x y z

Ans x

Simplify the Boolean Functions of Question 5 using K-map.

4.F4=xz+xy
Step#1 xz+xy
Xz(1)+(1)xy
Xz(y+ y)+x y(z+z)
Xyz+xyz+xyz+x yz

66
Islamabad Career Schools- Network Computer Notes - X

Step#1

YZ YZ YZ YZ
Xy z xyz xyz Xyz
X
xyz xyz xyz Xyz
X

Step#2
YZ YZ YZ YZ
1 1 0 0
X
X

Step# 3
Grouping
Group#1 xy 1 0 0 1 z, x y z=x y
Group#2 xy z, x y z=y z
Group#3 xy z,x y z=x z

Step#4
Apply Maxterm function

Ans x y+y z+x z

Draw logic circuits of the following Boolean functions.

1) F1= x y z + x y z

67
Islamabad Career Schools- Network Computer Notes - X

2) F2= x + y z
3) F3= x y + x y z+ x y z
4) F4= x+y + y z

F1= xyz + xyz

X
X XYZ
Y Y

Z
5
F1= X Y Z+ X Y Z
X

Y Y
Z
XYZ

F2= x + yz
X
X

y
F2= X + Y Z
YZ

68
Islamabad Career Schools- Network Computer Notes - X

F3= x y + x y z+ x y z

X XYZ

X
XYZ
Y F3=XY+XYZ+XYZ
Y
Z

X XY

F4= x+y+ y z
X
X+y
y
y

69
Islamabad Career Schools- Network Computer Notes - X

X+y+yz

Chapter 7:

Define the following terms.

web page
A document which can be displayed in a web browser such as
Firefox, Google Chrome, Opera, Microsoft Internet Explorer or Edge,
or Apple's Safari. These are also often called just "pages."

website
A collection of web pages which are grouped together and usually
connected together in various ways. Often called a "web site" or
simply a "site."

OR

Web server:

70
Islamabad Career Schools- Network Computer Notes - X

The web server on the other side is a computer program, which delivers
content, such as websites or web pages, for example, over the world wide
web from a web server to your computer.

search engine
A website that helps you find other web pages, such as Google, Bing,
or Yahoo.

Search engines can provide a great benefit

71
Islamabad Career Schools- Network Computer Notes - X

What does Search Engine mean?


Search engine is a service that allows Internet users to search for content
via the World Wide Web (WWW). A user enters keywords or key phrases
into a search engine and receives a list of Web content results in the form
of websites, images, videos or other online data.

Generally, people use search engines for one of three things:


research, shopping, or entertainment.

Search engines are an integral aspect of the online ecosystem.

URL

Stands for "Uniform Resource Locator." A URL is the address of a


specific webpage or file on the Internet.
For example, the URL of the TechTerms website is
"http://techterms.com." The address of this page is
"http://techterms.com/definition/url" and includes the following
elements:
1. http:// – the URL prefix, which specifies the protocol used
to access the location

72
Islamabad Career Schools- Network Computer Notes - X

2. techterms.com – the server name or IP address of the


server
3. /definition/url – the path to the directory or file
While all website URLs begin with "http," several other prefixes
exist.

Web Hosting

Web hosting is a service that allows organizations and individuals to post


a website or web page on to the Internet. A web host, or web
hosting service provide

Web hosting is a necessity for any website — it is the physical location of


your website on the Internet, an online storage center that houses the
information,

OR

A web hosting service is a type of Internet hosting service that allows


individuals and organizations to make their website accessible via
the World Wide Web. Web hosts are companies that provide space on
a server owned or leased for use by clients, as well as
providing Internet connectivity.

What is HTML?

HTML is the standard markup language for creating Web pages.

 HTML stands for Hyper Text Markup Language


 HTML describes the structure of Web pages using markup
 HTML elements are the building blocks of HTML pages
 HTML elements are represented by tags
 HTML tags label pieces of content such as "heading",
"paragraph", "table", and so on
 Browsers do not display the HTML tags, but use them to
render the content of the page

73
Islamabad Career Schools- Network Computer Notes - X

A Simple HTML Document


Example
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>

<h1>My First Heading</h1>


<p>My first paragraph.</p>

</body>
</html>
Try it Yourself »

Follow the four steps below to create your first web page with
Notepad or Text Edit.
Step 1: Open Notepad (PC) Windows 8 or later: ...
Step 2: Write Some HTML. ...
Step 3: Save the HTML Page. ...
Step 4: View the HTML Page in Your Browser

HTML Tags Ordered by Category

= New in HTML5.

74
Islamabad Career Schools- Network Computer Notes - X

Basic HTML

Tag Description

<!DOCTYPE> Defines the document type

<html> Defines an HTML document

<head> Defines information about the document

<title> Defines a title for the document

<body> Defines the document's body

<h1> to Defines HTML headings


<h6>

<p> Defines a paragraph

<br> Inserts a single line break

75
Islamabad Career Schools- Network Computer Notes - X

<hr> Defines a thematic change in the content

<!--...--> Defines a comment

Formatting

Tag Description

<abbr> Defines an abbreviation or an acronym

<address> Defines contact information for the author/owner of a


document/article

<b> Defines bold text

<bdi> Isolates a part of text that might be formatted in a


different direction from other text outside it

<bdo> Overrides the current text direction

<big> Defines big text

<blockquote Defines a section that is quoted from another source


>

76
Islamabad Career Schools- Network Computer Notes - X

<center> Defines centered text

<cite> Defines the title of a work

<code> Defines a piece of computer code

<del> Defines text that has been deleted from a document

<dfn> Represents the defining instance of a term

<em> Defines emphasized text

<font> Defines font, color, and size for text

<i> Defines a part of text in an alternate voice or mood

<ins> Defines a text that has been inserted into a document

<kbd> Defines keyboard input

<mark> Defines marked/highlighted text

<meter> Defines a scalar measurement within a known range (a

77
Islamabad Career Schools- Network Computer Notes - X

gauge)

<pre> Defines preformatted text

<progress> Represents the progress of a task

<q> Defines a short quotation

<rp> Defines what to show in browsers that do not support


ruby annotations

<rt> Defines an explanation/pronunciation of characters (for


East Asian typography)

<ruby> Defines a ruby annotation (for East Asian typography)

<s> Defines text that is no longer correct

<samp> Defines sample output from a computer program

<small> Defines smaller text

<strike> Defines strikethrough text

78
Islamabad Career Schools- Network Computer Notes - X

<strong> Defines important text

<sub> Defines subscripted text

<sup> Defines superscripted text

<template> Defines a template

<time> Defines a date/time

<u> Defines text that should be stylistically different from


normal text

<var> Defines a variable

<wbr> Defines a possible line-break

Forms and Input

Tag Description

<form> Defines an HTML form for user input

79
Islamabad Career Schools- Network Computer Notes - X

<input> Defines an input control

<textarea> Defines a multiline input control (text area)

<button> Defines a clickable button

<select> Defines a drop-down list

<optgroup> Defines a group of related options in a drop-down list

<option> Defines an option in a drop-down list

<label> Defines a label for an <input> element

<fieldset> Groups related elements in a form

<legend> Defines a caption for a <fieldset> element

<datalist> Specifies a list of pre-defined options for input controls

<output> Defines the result of a calculation

80
Islamabad Career Schools- Network Computer Notes - X

Frames

Tag Description

<frame> Defines a window (a frame) in a frameset

<frameset> Defines a set of frames

<noframes> Defines an alternate content for users that do not


support frames

<iframe> Defines an inline frame

Images

Tag Description

<img> Defines an image

<map> Defines a client-side image-map

<area> Defines an area inside an image-map

<canvas> Used to draw graphics, on the fly, via scripting (usually


JavaScript)

81
Islamabad Career Schools- Network Computer Notes - X

<figcaption> Defines a caption for a <figure> element

<figure> Specifies self-contained content

<picture> Defines a container for multiple image resources

<svg> Defines a container for SVG graphics

Audio / Video

Tag Description

<audio> Defines sound content

<source> Defines multiple media resources for media elements


(<video>, <audio> and <picture>)

<track> Defines text tracks for media elements (<video> and


<audio>)

<video> Defines a video or movie

Links

Tag Description

82
Islamabad Career Schools- Network Computer Notes - X

<a> Defines a hyperlink

<link> Defines the relationship between a document and an


external resource (most used to link to style sheets)

<nav> Defines navigation links

Lists

Tag Description

<ul> Defines an unordered list

<ol> Defines an ordered list

<li> Defines a list item

<dir> Defines a directory list

<dl> Defines a description list

<dt> Defines a term/name in a description list

<dd> Defines a description of a term/name in a description list

83
Islamabad Career Schools- Network Computer Notes - X

Tables

Tag Description

<table> Defines a table

<caption> Defines a table caption

<th> Defines a header cell in a table

<tr> Defines a row in a table

<td> Defines a cell in a table

<thead> Groups the header content in a table

<tbody> Groups the body content in a table

<tfoot> Groups the footer content in a table

<col> Specifies column properties for each column within a


<colgroup> element

<colgroup> Specifies a group of one or more columns in a table for

84
Islamabad Career Schools- Network Computer Notes - X

formatting

Styles and Semantics

Tag Description

<style> Defines style information for a document

<div> Defines a section in a document

<span> Defines a section in a document

<header> Defines a header for a document or section

<footer> Defines a footer for a document or section

<main> Specifies the main content of a document

<section> Defines a section in a document

<article> Defines an article

<aside> Defines content aside from the page content

85
Islamabad Career Schools- Network Computer Notes - X

<details> Defines additional details that the user can view or hide

<dialog> Defines a dialog box or window

<summary> Defines a visible heading for a <details> element

<data> Links the given content with a machine-readable


translation

Meta Info

Tag Description

<head> Defines information about the document

<meta> Defines metadata about an HTML document

<base> Specifies the base URL/target for all relative URLs in a


document

Programming

Tag Description

<script> Defines a client-side script

86
Islamabad Career Schools- Network Computer Notes - X

<noscript> Defines an alternate content for users that do not


support client-side scripts

<embed> Defines a container for an external (non-HTML)


application

<object> Defines an embedded object

<param> Defines a parameter for an object

NEW

Tag Description

<!--...--> Defines a comment

<!DOCTYPE> Defines the document type

<a> Defines a hyperlink

<abbr> Defines an abbreviation or an acronym

<address> Defines contact information for the author/owner


of a document

87
Islamabad Career Schools- Network Computer Notes - X

<article> Defines an article

<aside> Defines content aside from the page content

<audio> Defines sound content

<b> Defines bold text

<base> Specifies the base URL/target for all relative URLs


in a document

<basefont> Specifies a default color, size, and font for all text
in a document

<bdi> Isolates a part of text that might be formatted in a


different direction from other text outside it

<bdo> Overrides the current text direction

Defines big text

<blockquote> Defines a section that is quoted from another


source

88
Islamabad Career Schools- Network Computer Notes - X

<body> Defines the document's body

<br> Defines a single line break

<button> Defines a clickable button

<canvas> Used to draw graphics, on the fly, via scripting


(usually JavaScript)

<caption> Defines a table caption

<center> Defines centered text

<cite> Defines the title of a work

<code> Defines a piece of computer code

<col> Specifies column properties for each column


within a <colgroup> element

<colgroup> Specifies a group of one or more columns in a


table for formatting

<data> Links the given content with a machine-readable

89
Islamabad Career Schools- Network Computer Notes - X

translation

<datalist> Specifies a list of pre-defined options for input


controls

<dd> Defines a description/value of a term in a


description list

<del> Defines text that has been deleted from a


document

<details> Defines additional details that the user can view


or hide

<dfn> Represents the defining instance of a term

<dialog> Defines a dialog box or window

<dir> Defines a directory list

<div> Defines a section in a document

<dl> Defines a description list

90
Islamabad Career Schools- Network Computer Notes - X

<dt> Defines a term/name in a description list

<em> Defines emphasized text

<embed> Defines a container for an external (non-HTML)


application

<fieldset> Groups related elements in a form

<figcaption> Defines a caption for a <figure> element

<figure> Specifies self-contained content

<font> Defines font, color, and size for text

<footer> Defines a footer for a document or section

<form> Defines an HTML form for user input

<frame> Defines a window (a frame) in a frameset

<frameset> Defines a set of frames

91
Islamabad Career Schools- Network Computer Notes - X

<h1> to <h6> Defines HTML headings

<head> Defines information about the document

<header> Defines a header for a document or section

<hr> Defines a thematic change in the content

<html> Defines the root of an HTML document

<i> Defines a part of text in an alternate voice or


mood

<iframe> Defines an inline frame

<img> Defines an image

<input> Defines an input control

<ins> Defines a text that has been inserted into a


document

<kbd> Defines keyboard input

92
Islamabad Career Schools- Network Computer Notes - X

<label> Defines a label for an <input> element

<legend> Defines a caption for a <fieldset> element

<li> Defines a list item

<link> Defines the relationship between a document and


an external resource (most used to link to style
sheets)

<main> Specifies the main content of a document

<map> Defines a client-side image-map

<mark> Defines marked/highlighted text

<meta> Defines metadata about an HTML document

<meter> Defines a scalar measurement within a known


range (a gauge)

<nav> Defines navigation links

<noframes> Defines an alternate content for users that do not

93
Islamabad Career Schools- Network Computer Notes - X

support frames

<noscript> Defines an alternate content for users that do not


support client-side scripts

<object> Defines an embedded object

<ol> Defines an ordered list

<optgroup> Defines a group of related options in a drop-down


list

<option> Defines an option in a drop-down list

<output> Defines the result of a calculation

<p> Defines a paragraph

<param> Defines a parameter for an object

<picture> Defines a container for multiple image resources

<pre> Defines preformatted text

94
Islamabad Career Schools- Network Computer Notes - X

<progress> Represents the progress of a task

<q> Defines a short quotation

<rp> Defines what to show in browsers that do not


support ruby annotations

<rt> Defines an explanation/pronunciation of


characters (for East Asian typography)

<ruby> Defines a ruby annotation (for East Asian


typography)

<s> Defines text that is no longer correct

<samp> Defines sample output from a computer program

<script> Defines a client-side script

<section> Defines a section in a document

<select> Defines a drop-down list

<small> Defines smaller text

95
Islamabad Career Schools- Network Computer Notes - X

<source> Defines multiple media resources for media


elements (<video> and <audio>)

<span> Defines a section in a document

<strike> Defines strikethrough text

<strong> Defines important text

<style> Defines style information for a document

<sub> Defines subscripted text

<summary> Defines a visible heading for a <details> element

<sup> Defines superscripted text

<svg> Defines a container for SVG graphics

<table> Defines a table

<tbody> Groups the body content in a table

96
Islamabad Career Schools- Network Computer Notes - X

<td> Defines a cell in a table

<template> Defines a template

<textarea> Defines a multiline input control (text area)

<tfoot> Groups the footer content in a table

<th> Defines a header cell in a table

<thead> Groups the header content in a table

<time> Defines a date/time

<title> Defines a title for the document

<tr> Defines a row in a table

<track> Defines text tracks for media elements (<video>


and <audio>)

<tt> Defines teletype text

97
Islamabad Career Schools- Network Computer Notes - X

<u> Defines text that should be stylistically different


from normal text

<ul> Defines an unordered list

<var> Defines a variable

<video> Defines a video or movie

<wbr> Defines a possible line-break

REVIEW of All Chapters

Q: What is Problem Solving?


A:
To solve a problem using suitable software is called Problem Solving.

Q: What is meant by defining the Problem?


A:
It means knowing the objective of the Problem. It should include identification of
their input and the desired output of the program.
Q: What is Program?
A:
Program is a set of instructions according to the syntax (rules) of a Programming
language.
Q: What is Programming language?
A:
It is a set of letters, symbols, & numbers arranged according to the syntax of a
language used to write program.
Q: What is Pseudo-Code?
A:

98
Islamabad Career Schools- Network Computer Notes - X

It is a tool for writing a program or solution of a problem in narrative form using


natural human language. Pseudo-Code can not be compiled nor executed. Also it
Has no any syntax like algorithm.
Q: What is meant by analyzing the problem?
A:
It is the process of understanding the problem by asking series of Questions.
Example:
1.How to solve problem?
2.Can it be solved on computer?
3.What are input and output?
4 . H o w m a n y s o l u t i o n s a r e p o s s i b l e ? etc
Q: What is Problem identification Stage?
A:
It is 1ststage of program development. In which we define and analyze the problem
to understand it properly because only then we can write a proper program.
Q: Define Algorithm?
A:
It is a step by step procedure developed to solve a problem before writing an
actual program. It is a complete procedure or plan that describes the logic of
program.
Q: What is Flowchart?
A:
Flowchart is defined as, “The pictorial representation of the algorithm.”Or “The
graphical form of the detailed steps (algorithm) to solve a problem.”
Q: What is Coding?
A:
The process of converting the algorithm into a computer program using
computer language.
Q: Name the types of Computer’s instruction used in a Program?
A:
1. Input/ Output instructions.
2.Control instructions.
3.Arithmetic instructions.
4.Logical instructions.
5.Specification instructions.
Q What is purpose of Input/ Output instructions?
A:
Theses instructions direct the computer to move information to and from the
computer’s memory and an input or output unit.
Q: What is purpose of Control instructions?
A:

99
Islamabad Career Schools- Network Computer Notes - X

These instructions control the order in which other instructions are executed by
transferring the control to the instruction executed next.
Q: What is purpose of Arithmetic instructions?
A:
These instructions direct a computer for Arithmetical Computations and moving
data from one place to another in memory.
Q: What is purpose of Logical instructions?
A:
These instructions enable the compute
r to compare items of data and proceed according to the result of the comparison
whether certain condition is true or false.
Q: What is purpose of Specification instructions?
A:
These instructions are descriptive. A programmer can inform a
computer about things such as the types of data items used in a program,
the allocation of storage so on and so forth.
Q: What types of Errors can be occurs during Testing?
A:
Three types of Errors can be occurs during
Testing:1. Logical/Semantic Errors
.2. Syntax/Compiler Errors.
3. Run time/Execution Errors.
Name the types of numeric constant?
A
: 1) Integer Constant.
2) Fixed-Point Constant.
3) Floating-Point Constant.

Q: Define floating-point constant?


A:
● Positive or negative numbers are represented in exponential
form.● Consist of an optional-signed integer or fixed point number (the
mantissa), followed by the letter E and optional-signed integer (the
exponent.)
Example:
235.988E-72359E6
Q: Name types of variables?
A:

100
Islamabad Career Schools- Network Computer Notes - X

1) Numeric Variable.2) String Variable.

Q: Define Numeric Variable?


A:
Numeric Variable always has numeric values. A numeric variable name
may consist of all alphabets and numeric constants but must begin with
an alphabet. Special Characters and blank spaces are not allowed . it can
be Integer, Single- Precision and Double-Precision. Valid variable name
are: A, B2, X55, NUM, TPAY etc.

Q: Define String Variable?


A:
It represent a character string that is a character or a sequence of
characters i.e. letters, numbers and special characters. Blank spaces
may include in a string but not the quotation marks. It must be followed
by $ sign such as A$, B33$, GRAD$ etc.

Q: Define Operator? Name its types?


A:
An Operator performs mathematical or logical operations on values.
These are divided into 4types:
● Arithmetic Operator.
● Logical Operator.
● Relational Operator.
● Functional Operator.

Q: Define Relational Operator?


A:
It is used to relate or compare two quantities. The result of comparison
may be either “Yes” or “No” or may be “True” or “False”

Q: Define Logical Operator?


A:
It perform tests on multiple relations, bit manipulation, or Boolean
operations. It returns a
bit-wise results, which is either true(non-zero) or false(zero).

101
Islamabad Career Schools- Network Computer Notes - X

Example:
NOT(Unary),
AND,
OR etc.

Q: Define Arithmetic Operator?


A:
Numeric expressions contain operators that perform arithmetic
operations as addition, subtraction, multiplication, division etc.
Example:
+, -, *, /, ^, \(integer division), mod(modulus)● Two additional
arithmetic operators are also available known as integer division and
modulus arithmetic.● Integer division is denoted by (\). The operands
are rounded to integers before the division is performed and the quotient
is truncated to a lower integer.● The mod operator denotes
modulus arithmetic. It returns remainder of an integer division.

Q: Define Functional Operator?


A:
These are built in functions used to perform arithmetic and string
operations.
Example:
ABS, INT, FIX etc.

Q:Define Computer.
A computer is an electronic data processing device. It reads data
processing and
produces results accurately at a very high speed.

Q:What is algorithm and what is the role of algorithm in problem


solving?
Algorithm:
Algorithm means method, procedure, technique or plan.
It is a step-by-step problem solving method.
It is easy to understand and follow.
It is a set of steps that clearly defines a sequence of operations to solve a
problem.

102
Islamabad Career Schools- Network Computer Notes - X

Role of Algorithm in Problem Solving:


Algorithm plays an important role in computer programming.
Computer programming is the process of taking an algorithm and coding it
in a programming language.

Formulating an algorithm is the first step for developing a computer


program.

Q:What is a flowchart?
Flowchart is a diagrammatic representation of algorithm. It describes what
operations
are required to solve a given problem.

Q:What are the advantages of using flowcharts?


Flowchart illustrates the sequence of operations to be performed to solve a
problem.
Programmers draw flowcharts before writing computer programs.
Flowchart provides an easy way to analyze and find solutions of problems.
Once, the flowchart is drawn, it becomes very easy to write the program in
any
high level language.
Flowchart is very helpful in communicating the problem solving method to
other
people.
It also helps in finding and removing errors in computer programs.

Q:What do you know about programming language?

programming language is a vocabulary and set of grammatical rules for


instructing a computer or computing device to perform specific tasks. The
term programming language usually refers to high-level languages, such
as BASIC, C, C++, COBOL, Java, FORTRAN, Ada, and Pascal.

Visual C++
An application development tool developed by Microsoft for
C++programmers. Visual C++ supports object-oriented programming of 32-
bit Windows applications with an integrated development environment
(IDE), a C/C++ compiler, and a class library called the Microsoft
Foundation Classes (MFC).

103
Islamabad Career Schools- Network Computer Notes - X

C#
# is a hybrid of C and C++, it is a Microsoft programming language
developed to compete with Sun's Java language. C# is an object-
oriented programming language used with XML-based Web services on
the .NET platform and designed for improving productivity in the
development of Web applications.

Basic Control Structures


In a program, a control structure determines the order in which statements
are executed. The following are the basic control structures in the
programming languages:

Sequential
In Sequential execution each statement in the source code will be executed
one by one in a sequential order. This is the default mode of execution.

Selection
The selection control structure is used for making decisions and branching
statements, the following are the basic selection statements in the
programming language.
Loop
In computer programming, a loop is a sequence of instruction s that is
continually repeated until a certain condition is reached. Typically, a certain
process is done, such as getting an item of data and changing it, and then
some condition is checked such as whether a counter has reached a
prescribed number.

Operators in C / C++
Operators are the foundation of any programming language. Thus the
functionality of C/C++ programming language is incomplete without the use
of operators. We can define operators as symbols that helps us to perform
specific mathematical and logical computations on operands.

104
Islamabad Career Schools- Network Computer Notes - X

Arithmetic Operators: These are the operators used to perform


arithmetic/mathematical operations on operands. Examples: (+, -, *, /, %,+
+,–).
Arithmetic operator are of two types:

1. Unary Operators: Operators that operates or works with a single


operand are unary operators.
For example: (++ , –)
2. Binary Operators: Operators that operates or works with two
operands are binary operators.For example: (+ , – , * , /).

Relational Operators: Relational operators are used for comparison


of the values of two operands.

Logical Operators: Logical Operators are used to combine two


or more conditions/constraints or to complement the evaluation of the
original condition in consideration.

Assignment Operators: Assignment operators are used to assign


value to a variable. The left side operand of the assignment operator is a
variable and right side operand of the assignment operator is a value.
How many types of loop?
There are the three types of loops.
1) while
2) do-while
3) for
Nested loop
A nested loop is a loop within a loop, an inner loop within the body of an
outer one.

K-MAP

105
Islamabad Career Schools- Network Computer Notes - X

A Karnaugh map (K-map) is a pictorial method used to


minimize Boolean expressions without having to use Boolean algebra
theorems and equation manipulations. A K-map can be thought of as a
special version of a truth table .

Source Code
A program written in high-level language is called as source code

Different type of translators


The different types of translator are as follows:
Assembler
Assembler is a translator which is used to translate the assembly language
code into machine language code.

Compiler
Compiler is a translator which is used to convert programs in high-level
language to low-level language. It translates the entire program and also
reports the errors in source program encountered during the translation.

Interpreter
Interpreter is a translator which is used to convert programs in
high-level language to low-level language. Interpreter translates

106
Islamabad Career Schools- Network Computer Notes - X

line by line and reports the error once it encountered during the
translation process.

Differences between compiler and interpreter

SI. Compiler Interpreter


No

1 Performs the translation of Performs statement by


a program as a whole. statement translation.

2 Execution is faster. Execution is slower.

3 Requires more memory as Memory usage is efficient as no


linking is needed for the intermediate object code is
generated intermediate generated.
object code.

4 Debugging is hard as the It stops translation when the


error messages are first error is met. Hence,
generated after scanning debugging is easy.
the entire program only.

5 Programming languages Programming languages like


like C, C++ uses compilers. Python, BASIC, and Ruby uses
interpreters.

Sample C Program:
#include<stdio.h> <———————-Preprocessing Directive

void main()

107
Islamabad Career Schools- Network Computer Notes - X

{ <——————–Start of a Program

/*………….Printing Starts………….*/

Printf(“Learn at every moment”);

/*………….Printing starts……..*/

} <———————-End of a Program

 In C many library functions are grouped category-wise and stored


in different files known as header files. Ex. stdio.h–>standard input
output header file
 To use the functions defined in the header file that need to be
included in the program
 This can be achieved by the preprocessing directive “#include”
 “#include” includes the content of header file(stdio.h) at the
beginning of program.

Input and Output Functions in c


Objectives
Having read this section you should have a clearer idea of one of C's:
1. input functions, called scanf
2. output functions, called printf

Uses of C

C was initially used for system development work, in particular the


programs that make-up the operating system. Why use C? Mainly because
it produces code that runs nearly as fast as code written in assembly
language. Some examples of the use of C might be:

1. Operating Systems
2. Language Compilers
3. Assemblers
4. Text Editors
5. Print Spoolers
6. Network Drivers
7. Modern Programs
8. Data Bases
9. Language Interpreters
10. Utilities

108
Islamabad Career Schools- Network Computer Notes - X

Order of Precedence of Operators for Calculations


1. The order in which operator are performed determines the result.
Consider the expressions 3 + 4 * 2. Over here if addition is done first, the
result is 14. However, if multiplication is done first then result is 11.
2. The hierarchy of operations, or order of operations, or order of
precedence, in arithmetic expressions from highest to lowest is:
a. Exponentiation
b. Multiplication and Division
c. Addition and Subtraction

3. In the previous example, the multiplication is done before addition, and


the result is 11. to change the order of evolution, use parenthesis:
(3 + 4) * 2 will yield 14 as the result. One set of parenthesis can be used
inside another set. In the case, parenthesis are said to be nested.

Hyperlink

A hyperlink is an element in an HTML document that links to either another


portion of the document or to another document altogether. On web pages,
hyperlinks are usually colored purple or blue and are sometimes
underlined.

109

You might also like