CHAPTER-1:Computer System and Devices
Answer the following:
1.How does the key pressed on keyboard reach the computer?
Ans: When we press a key on the keyboard,the key pressed is stored in a
buffer,known as keyboard buffer.The hardware checks of the presence of data in
this buffer,alomg with other buffers that are present in the computer.Since the
speed of the computer is very high,When we type the characters with the help of
keyboard,it instantly apperas on the monitor.
2.What is the purpose of MAR?
Ans. A CPU register that either stores the memory adress from which data will be
fetched to the CPU or the adress to which data will be sent and stored.
3.What are the differnt kinds of monitor?Explain.
Ans. There are two kinds of monitors.
1.LCD monitors
2. CRT monitors
CRT monitors look much like old-fashioned televisions and very deep in size.
LCD monitors are much thinner,use less energy and provide a great graphics
quality.
CHAPTER-2: Programming in BASIC
BASIC is aprogramming language used well for building begginer’s concepts
regarding programming.
Control statement:
The statements that governs the flow of control of the script rae called control
statements.
Their are two types of control statements
1.Conditional statement
2.Iterative statement
Conditional statement:
Conditional statements perform comparisons and take appropriate actions
depending on the outcome of such comparisons..BASIC provides IF—THEN—
ELSE conditional statement.
IF—THEN—ELSE :statement is used to evaluate whether a condition is TRUE
or FALSE and,depending on the result it allows one or more statements to
execute.Every IF ststement should terminate with an END IF.
Syntax:
IF condition THEN
Statement(s)
ELSE
Statement(s)
END IF
IF—THEN:This stsement form of the IF—THEN—ELSE statement.
In this,If condition stands true then the program wil execute the
statement(s)following it and if condition stands false then the program will not
execute the following statement.
For Example:
Program to accept marks and print “YOU SCORED WELL” if marks are
greater then or equal to 80.
PRINT “Enter marks”
INPUT Marks
IF Marks>=80 THEN
PRINT “YOU SCORE WELL”
END IF
END
IF---THEN---ELSE:
In IF—THEN—ELSE if the condition stands true statements(s) folllowing IF gets
executed but if the condition false statement(s) following ELSE gets execute.
For example:
Program to accept a number and check if it is odd or even
PRINT “Enter any number”;
INPUT NUM
IF NUM od 2=1 THEN
PRINT “The number is odd”
ELSE
PRINT “The Number is not odd”
END IF
END
Iterative statements:
Iterative statements or loops used to repeat an action again and again for a
specific number of times.Some of the looping constructs in BASIC are:
For------NEXT
WHILE-----WEND
For------NEXT:This loop is used to executeset of statement or set of statemnts
for a specific number of times.It uses a counter veriable which is incremented or
decremented with each repetation of loop.
Syntax:
For <counter> = <start> To <End> STEP <Increment>
Statement(s)
NEXT <counter>
Counter is a variable for counting
Start is the initial value of counter
Count is the finall value of counter
Increment means change.It amy be positive or neagtive.
Example:
Program to print the numbers from 1 to 10
For I=1 to 10 STEP 1
PRINT I
NEXT I
END
WHILE----WEND:This loop is used to execute a statement or set of statements
as long asthe condition being checked stands true.
Syntax:
WHILE <condition>
< Statement(s)>
WEND
Example:
Program to print the square of numbers from 1to 20.
I=1
WHILE I<=20
PRINT “square of”;I;” is “;I*I
WEND
END
Arrays:
An array is a type of variable that groups a series of values and places them in a
single variable.thase sre useful when you need to store a similar type of dat
because they make it easeier tomanipulate the data together.Array is declared
using the keyword DIM.
Syntax to declare array:
DIM ArrayName(Num)
Where ArrayNam is name of the array
Num is the number of elements in the array.
Example:
DIM MARKS(10)
Answer the following:
1.Define control statement.Mention the types with example.
Ans.The statements that govern the flow of control of the script are called as
control statements.
Their are two types of control statements:
Conditional statements: IF--THEN, IF—THEN—ELSE.
Iterative statements: For—NEXT, WHILE---WEND.
2. Define Iterative statements.Mention the types with example.
Ans: Iterative statements or loops used to repeat an action again and again for a
specific number of times.Some of the looping constructs in BASIC are:
For------NEXT
WHILE-----WEND
3. What are Array.Write the syntax to declare an array.
Ans. An array is a type of variable that groups a series of values and places them
in a single variable.
Syntax: DIM ArrayName (Num)
4.Write a program to evaluate the H>C.F of two positive integers.
PRINT “Enter Two numbers”
INPUT “Enter first number:”;NUM1
INPUT “Enter Second number:”;NUM2
WHILE NUM1!=NUM2
IF NUM1>NUM2
NUM1=NUM1-NUM2
ELSE
NUM2=NUM2-NUM1
PRINT “HCFof two numbers”;NUM1
END IF
WEND
END
5. Write a program which take 10 numbers as input and output the average.
Ans.
DIM NUMARR (10)
SUM=0
FOR I= 1 To 10
INPUT “Enter the number:”; NUMARR (I)
SUM=SUM+NUMARR (I)
NEXT I
AVG=SUM/10
PRINT “The average is “;AVG
END
6. Write a program to print the squares of each of the first ten even numbers,one by one.
LET Even=2
LET Counter=0
WHILE Counter<10
PRINT “squares of “;Even;”is”;Even*Even
Counter=Counter+1
Even=Even+2
WEND
END
7.Writea program to find the sum of first ten fibonacci numbers(starting from 1)
CLS
DIM FIB(10)
SUM=0
FIB(2)=1
FIB(1)=1
For I= 3 To 10
FIB(I)= FIB(I-1) + FIB(I-2)
NEXT I
For I=1 To10
SUM=SUM+FIB(I)
NEXT I
Print “The required sum:”SUM