Professional Documents
Culture Documents
Class 10 Computer Notes
Class 10 Computer Notes
When this program is run, it asks for values and then displays the output as:
? 10, 20, 30
1-
OK.
This works quite fine. However, if we enter 0 values for C means want to divide the sum of A and B by 0 then the
computer displays the following errors message:
? 10,20,0
Division by zero
OK.
The rules for written single loops apply to nested loops. Other rules are;
1. Each nested loop must begin with its own FOR-TO statement and end with its own NEXT statement.
2. An outer loop and an inner lop cannot have the same index variable.
3. Each inner (nested) loop must be completely embedded with in the outer loop i.e; the loops cannot overlap.
4. Control can be transferred from an inner loop to a statement in an outer loop or to a statement out side of the entire
nest. However, control cannot be transferred to a statement with in a nest from a point out side the nest.
Q NO 3:-What is the difference between?
Loop: - a loop is a set of statement which is executed repeatedly.
Nested loop: - By nested loops we mean one loop within another loop.
Conditional transfer of control statements: - Those statements which transfer control to other part of the program based
on same condition are known as conditional transfer of control statements e.g. IF/THEN/ELS.
Unconditional transfer of control statements: - Those statements which do not need any condition to jumps form one
part of the program to another e.g., GOTO, ON, GOTO.
IF/THEN/ELSE and ON/GOTO statements: - It is similar to the IF-THEN statement, with an added power to transfer
control to another part of the program whether the condition is true or false.
e.g., 10 IF marks>33 THEN PRINT PASSELSE PRINTFAIL
5
THE ON/GO TO statement: - It is multiple branching unconditional transfer of control statement which is used to
transfer control to any one of the indicated line numbers.
e.g., 40 on choice GO TO 15,35,60,100,60.
FOR/NEXT LOOP statement: - This is a loop which is used to perform repetitive tasks and is used when we know in
advance the number of times the loop will be executed.
WHILE/WEND LOOP statement: - It is used when the numbers of repetitions are not known in advance. It has the
capability to be terminated any time depending on the condition.
Chapter- 5 "Subprograms"
Subprograms:- A subprogram is a set of statements which are written once in the program and used or called many
times in different places of program.
Basic language offers two types of sub programs.
1:-subroutnes subprograms
2:-functions Subprograms
Functions Subprograms: - Functions are those sub programs which are used to replace simple process such as
calculating the square of a number, finding out the natural logarithm of a number and so on.
Subroutines subprograms: - Subprogram which are used to do complex programming operations like calculating the
roots of a quadratic equation, solving a matrix and soon.
What is the purpose of intrinsic functions? Why do we use them? Explain with suitable examples the different
types of intrinsic functions.
Purpose of intrinsic: - They perform the most basic operations like calculating the square root, sine, cosine, tanguage of
angles and so on.
Why do we use them: - When we want to solve the most basic operations like calculating the square root, sine, cosine,
tanguage of angles and so on then we use intrinsic functions.
Types of intrinsic functions: - Then are categorized follows:-
1. Numeric function: - The number of built-in functions which can be used for mathematical calculations. These
functions return a number as their results.
They are:-
Trigonometric functions:-
Functions purpose
Sin(X) Calculates the sine of X.
Cos(X) Calculates the cosine of X.
Tan(X) Calculates the tangent of X.
Atn(X) Calculates the tangent inverse (arctangent) of X.
Arithmetic functions:-
Functions purpose
SQR(X) Calculates the square root of a given number.
LOG(X) Calculates the natural logarithm of X.
EXP(X) Calculates the exponential value of X.
2. String Functions:- The number of built-in functions which can be used for manipulations of string data. These
functions return string and numeric values as their result. They are:-
Functions purpose
LEFT$(Sring,n) Selects the left most n characters of the given string.
If n is greater then the number of characters
Contained in the string, the entire string will be printed.
RIGHT$(String,n) Selects the right most n character of the given string.
3. String$ functions:- This string functions is used to repeatedly print out a character specified by the given ASCII
number to the function STRING$. This functions has the following general form:
STRING$(N,M).
Exp:- 60 PRINT STRING$(3,67)
4. Time$ functions:- The TIME$ is a built-in functions in BASIC which is related with system time. It is used to show the
current time or used to set the new time of the system.
Exp:- 10 PRINTTIME$ and
20 TIME$ =16:00:00
5. Date$ functions:- Like time$ functions Date$ functions is used to display the current date, or set the new date of the
system. The general syntax as:-
Line DATE$.
Exp:- 10 DATE$ =03-07-2001
6. ASC functions:- It is the inverse of CHR$ function, which returns corresponding character for a given ASCII value,
because it returns the ASCII code for a given character. Its general form is : ASC(X$)
10 PRINT ASC (ABC).
7. LEN Function:- This function is used to print the total number of characters contained in the string. It has the general
from like.
LEN(X$)LEN () Will print 0 where
LEN (Nafid ullah khan).
8. VAL function:-This function is used to return to return the numeric value of the given string argument in a string of
numbers enclosed in the double quotation. It must be noted that the string must be the combination of number. Its
general form.
VAL(X$)
Exp:- A$= 852772
9. OCT$ function:- This functions is used to calculate the equivalent of a decimal number in the octal number system.
The general form:
OCT$(Decimal Number).
10. HEX$ function:- That is used to calculate the Hexadecimal equivalent of a number which is in the decimal number
system. The general form:
HEX$(Decimal Number).
7
CHAPTER 6 Graphics
What is meant by computer graphics? What do you know about different modes of graphics in BASIC?
Explain.
Computer graphics: - Graphics is that area of computer programming which is highly in use these days. It is that type of
programming in which we draw text or pictures i.e., shape and images on the screen of the computer.
Types of Graphics: - There are three modes of drawing Graphics.
1. Text Mode: - It is the first mode of drawing graphics and it refers to drawing number, letter and special characters
(like $, % and so on) in the graphics form like high lighting, make them blinking or to convert them into invisible form.
In text mode these characters are displayed in terms of 25 rows x 40 columns or 25 rows x 80 columns on the screen
of the computer monitor.
2. Medium-Resolution Graphics Mode:- In this mode of Graphics, the display is divide into a matrix consisting of 320
columns and 200 rows of pixels. This graphical mode works with 4 columns. The columns are numbered from 0 to 319
and the rows from 0 to 199.
3. High-resolution graphics Mode: - High-Resolution graphics Mode contains more pixels than the medium resolution
mode. In this mode the screen is divided into 640 columns and 200 rows which make a matrix of 640 x 200 pixels. This
high resolution is used to facilitate more precise and clear drawing of graphics.
Why do we use CIRCLE statement? Explain with suitable example.
Some time we need to make a circle. In order to draw a circle, we use the CRICLE statements. This statement has the
following general form:
Line# CRICLE(X, Y), radius [colour].
Where (x,y) is the position of the point that is located at the center of the circle and radius is the radius of the circle. The
colour value is optional and is used to colour the circle with specific colour selected according to the graphic mode and
the available colour palette. An example may be:
20 CIRCLES (110,150), 70
Which is used to draw a circle of radius equal to 10 and having the pixel located at?
(110,150) as its center.
Example: - This program is used to draw a circle one with in another by using CRICLE statements, as following:
10 CLS
20 SCREEN 1
30 FOR = 60 TO 10 STEP 10
40 CRICLE (100,50);I
50 NEXT I
60 END
Write the purpose and complete syntax of DRAW statements. What types of shapes you can draw with this
statement? Give two examples.
This statement is used to draw lines and other shapes on the screen of the monitor. This statement is used in both the
resolution graphics modes, which are the medium resolution and high resolution graphics mode.
The general form of DRAW statements is:
Line # DRAW string
Where string may be enclosed in quotes and its contain commands to create a shape on the screen. This string may
be using one of the following commands:
Un is used to move up n points or pixels.
Dn for moving down by n points or pixels.
Fn for moving left n points or pixels.
R for moving right n points or pixels.
En for moving diagonally down and right by n points i.e., pixels.
Gn for moving diagonally down and left by n points i.e., pixels.
Hn for moving diagonally up and left by n points or pixels.
When one of these commands is executed, a line is drawing n from the starting position which has been specified.
Thus this drawing utility of BASIC language is used to specify the number of points or pixels and the specific direction
in which the line is to be drawn.
By DRAW statements we draw the following shapes:-
This program is used to draw a square.
10 CLS
20 SCREEN 1
30 DRAWU40L50D40R50
Program 2:- This program is written to draw a rectangle.
10 CLS
20 SCREEN 1
30 DRAW U40R70D40L70
What is the role of SCREEN statements? Write down its different modes and their effect on the graphic quality.
SCREEN statement:- SCREEN statement insert effect on the graphic quality.
It must be notified that the statement SCRREN 1 is used to select an appropriate screen mode i.e., Medium Resolution
graphics mode. The general form of the SCREEN statement is:
Line # SCREEN Mode.
There are three modes of SCREEN statement:-
1. Mode = 0:- If mode = 0 that is, SCREEN 0, then text is selected.
2. Mode = 1:- If mode = 1 that is, SCREEN 1, then Medium Resolution mode of graphic will be set.
3. Mode = 2:- If mode = 2 that is, SCREEN 2, then High Resolution mode of graphic will be set.
8
REM STATEMENT: - REM Statement is used to include comments/remarks in BASIC program. This statement
consists of statement number followed by the keyword REM, followed by any remarks. It has the following general
form:
1. Line # REM [OR,] Any Comments.
Exp:
10 This is a comment line.
END STATEMENT:- END statement is used to terminate the execution of the program. It can be given anywhere in the
BASIC program physically but logically it must be the very last statement of the program. Though the END statement is
optional to use, but it is a good programming practice to include the END statement in all BASIC programs. The END
statement has the following format:
LINE# END
LOOP: A loop is an instruction or group of instruction that the computer executes repeatedly to a specified number of
time or until some terminating satisfied
Or
Repetition of statement
1:
10 For I=2 to 20
20 Print I
30 next
2:
10 For I = 2 to 20 step 2
20 print I
30 next
BASIC COMMANDS OF BASIC LANGUAGE
Auto Commands (Alt+A):-
Auto Commands are used to generate the line number automatically.
Syntax: - Auto (Enter).
Syntax: - Auto 2 (Enter).
Syntax: - Auto 100 (Enter).
Syntax: - Auto 10, 50 (Enter).
Syntax: - Auto 100,100 (Enter).
To End Page Break: - Clt+Break.
List Commands (List). (F1)
Its produce the entire list of the program on the screen.
Syntax: - List (Enter).
Syntax: - List 40 (Enter).
Syntax: - List 100-200 (Enter).
Syntax: - List -80 (Enter).
Syntax: - List 80 (Enter).
Run Commands (F2).
To execute the Basic program.
Syntax: - Run (Enter).
Load Commands (F3).
To load a program to disk into memory.
10
CHAPTER NO 4
1. An array element is referenced by using array name and Positions.
2. A (2) and B (3, 4) are called Subscripted variables.
3. Array element A (4) represents Individual elements the element of the array A.
4. There are two types of arrays in BASIC One Dimensional array and Two- Dimensional array.
5. The first subscript of a two-dimensional array represents Number of Rows and the second one represents Number of
Columns.
11
CHAPTER NO 5
1. There are two types of subprograms Function Subprogram and Subroutine Subprogram.
2. Numeric functions return Number values.
3. Trigonometric functions are Numeric Function.
4. STR$ is used to Convert a numeric value to its string.
5. INKEY$ is used to To read the character from the keyboard.
6. ASC function is the reverse of CHR$ function.
7. LEN is used to Print the total number of character contained in the string.
8. VAL function is the reverse of ___function.
9. User-defined functions are defined with DEFFN statement.
10. Control is transferred to a subroutine through GOSUB statements.
CHAPTER NO 6
1. There are three modes of drawing graphics namely Text mode, Medium Resolution Graphic Mode and High-
Resolution Graphic Mode.
2. SCREEN 0 represents Text Mode.
3. In text mode characters are displayed in term of 25 rows x40 columns or 25 rows x80 columns.
4. The width statement is used to ____
5. In medium resolution graph mode screen is divided in to 320 columns and 200 rows of pixels.
6. In medium resolution mode right lower corner is represented by (319,199).
7. In high resolution graphic mode screen is divided in to 640columns and 200 rows of pixels.
8. The syntax of draw statement is Line# DRAW String.
9. In draw statement we use Dn for moving down n point.
10. The color statement is used to select a specific color for our graphical object.
CHAPTER NO 7
1. MS-Word stands for Microsoft Word.
2. Word Star is a Word Processing program.
3. Bold is used to
4. In order to underline a text we use Underline button on formatting bar.
5. To set the margins of a document we use page setup option in the file menu.
6. Footnote option is located in the Insert menu.
7. To set spacing of line in a paragraph we use Line spacing option.
8. To check spelling we use Spelling and Grammar option.
9. To delete a column from a table we use Delete then column option in the table menu.
10. To select a printer we use Print option.