Computer Science Basics Guide
Computer Science Basics Guide
UNIT-A
Chapter - 1 Configuring a Computer
u
Ans. It decodes the instructions.
. d
7. What is the purpose of Instruction Decoder?
e
8. What is a data bus?
w w
Ans. w
It carries a word to or from memory.
9. What is an address bus?
Ans. It carries memory address. The width of address bus equals the number of bits in the
MAR.
10. What is the function of control bus?
Ans. It carries signals between the units of the computer.
11. Name different I/O ports.
Ans. Port is a socket on the back of computer. Different types of ports are serial ports, parallel
ports and USB ports.
12. What is meant by plug and play cards?
Ans. It enables the user to add devices to computer.
13. Expand SD RAM.
Ans. Synchronous Dynamic Random Access Memory.
14. Expand DDR RAM.
1
Ans. Double Data Rate Random Access Memory.
II Two Marks Questions.
1. Explain USB Port (Universal Serial Bus).
Ans. a. It is a high speed serial bus
b. It is a plug and play interface between computers and add on devices.
2. Give the specifications of Laser printer.
Ans. a. Resolution varies from 600 to 1200 dots per inch.
b. Speed varies from 4 PPM to 24 PPM.
c. Buffer size varies from 4MB to 32 MB
d. Can print color images.
3. Give the specifications of dot matrix printer.
Ans. a. Print head normally has 9 pins to 24 pins.
b. Speed varies from 30 to 300 characters per second.
c. Buffer size varies from 1K to 64 K.
4. Give the specifications of inkjet printer.
Ans. a. Resolution is around 300 dots per inch.
b. Speed varies from 1PPM to 12 PPM
c. Buffer size varies from 1 MB to 4 MB.
s t
III Five Marks Questions:
1) Write a note on computer maintenance.
.h o
Ans: a. Avoid heat dust and noise
b. Periodic updates and enhancements
a re
c. Installing fire walls and anti virus.
u c
d. In house software maintenance
e. Computer periodic checkup.
.e d
Ans: Threats
w w
2) What are the possible threats to a computer system and how to provide security?
a. Privacy
b. Integrity w
c. Environmental damage
d. Human threats
e. Software threats
f. Unauthorized access
g. Computer viruses
Security
a. Physical protection of machine and media.
b. Giving passwords and users ID
c. Using Licensed software
d. Use of Cryptography
e. Use of Spike busters and UPS
3) Explain the typical causes of computer failures.
Ans: a. Break down of components.
b. Excessive dust or humidity
c. Virus
d. Voltage fluctuation
2
e. Corrosion
4) Write a note on Computer virus.
Ans: Viruses are collection of coded instructions which are self replicating. When a virus attaches
itself to another file it infects it. They are normally inactive until infected program is run.
They are broadly classified into three categories.
a. Boot infectors
b. System infectors
c. Executable program infectors
Boot infectors: Create bad sectors. They remain in the memory until the system is shutdown.
System infectors It infects the hard disk or: bootable floppies which may contain system files.
Executable program infectors: These are dangerous and devastating. They spread to
almost any executable program attaching themselves to programming files.
5. Explain the cache memory in detail.
Ans: Cache memory is a small and fast memory between CPU and main memory. It is extremely fast
compared to normal memory. Transferring data between main memory and CPU causes delay because
RAM is slower than CPU. Cache memory stores copies of data from most frequently used main memory
locations. When processor needs to read from or write to a location in main memory, it first checks
whether a copy of data is in the cache. If so processor immediately reads or writes to cache. Computers
use multilevels of cache such as Level1(smallest)and Level2 cache.CPU resident cache is known as L1
s t
or primary cache (16 to 32 KB) to 512 KB.Cache is also added to mother board also known as L2 cache
L2 RAM
. o
(512 KB to 1024 KB). Higher end systems can have as much as 2 MB of L2 cache on mother board.
h
CPU
cache
a re
u c
.e d
i/o units
Bridge
w w drivers
keyboard
. w
6. Write a note on components of motherboard.
t
Ans: 1) Bus : -
a. Address Bus
b. Data Bus
c. Control Bus
2) Expansion slots: They serve the purpose of adding functionality to the computer.
a. ISA : Industrial standard architecture.
b. PCI : Peripheral component interface
c. AGP : Accelerated Graphic port.
3) CACHE Memory: It is a small fast memory that resides between CPU and main
memory.
4) CMOS (Complementary Metal Oxide Semiconductor Battery )
5) I-O Ports ( Input –Output Ports ): Serial , Parallel , USB etc.,
7. Explain the different factors affecting the processing speed of CPU.
3
• Ans: CPU Speed/Clock speed: Speed of CPU also known as clock speed. The clock speed is the
number of instructions executed by the CPU in one second It is measured in megahertz(million
instructions per second). The average speed of a new CPU is about 1000MHz to 4000 MHz.(1 to 4 giga
hertz).
• Instruction set: The number of instructions decide the efficiency of a CPU. More the instructions , less
efficient is the CPU and less the instructions, More efficient is the CPU.
• Word size/Register size: The size of registers determines the amount of data the computer can work
with at a time. Normally it is 32 bits. Smaller the size of register, slower will be the computer. . It is also
known as Word size. It varies from 16 bits to 128 bits.
• Data bus capacity: Width of a data bus determines the largest number of bits that can be transported at
one time.
• Cache Memory size: Cache memory is a high speed memory. Greater the cache, faster a processor
runs. Most modern processors can execute multiple instructions per clock cycle which speeds up a
program. Some CPU’s have storage for instructions and data built inside the processor chip . This is
called internal cache or L1 cache memory.
• Memory Size: The amount of PRIMARY STORAGE (RAM) determines the size of program that can
be kept in primary storage, which is faster than secondary storage. There by the speed of computer
increases. The size of RAM varies from 64 MB to 4 GB.
s t
Ans: Program counter: This register stores address of next instruction to be executed.
h o
Memory address register (MAR): This register specifies address in memory where information can be
found. This register is also used to point to a memory locations where information can be stored.
.
re
Memory buffer register: This register acts as an interface between CPU and memory. When CPU
a
issues a Read Memory command, instruction is fetched and placed in MB register.
u c
.e d
Instruction register-This stores a copy of current instruction.
Instruction decoder (ID): ID is an electronic hardware, which decodes instructions. The instructions are
w
further broken down into a set of micro operations, so that they can be executed directly.
w
w
General purpose registers: They are used to store data. There are 6 GP registers. These are used for
storage of data as needed by the program.
Arithmetic logic unit: The basic arithmetic operations such as addition,subtraction,multiplication and
division are carried out here. These operations need atleast two operands, one which is stored in
accumulator and the other in the MBR. After the manipulation of data in ALU, the result is transferred to
accumulator.
Accumulator: During processing the intermediate data needed for future processing is stored in
accumulator. The contents of ACC are used by ALU for operations and later by MBR holds the final
result for further action.
4
Chapter - 2 Problem Solving Techniques
UNIT-B
I One Mark Question and Answer
1) Define Sorting.
Ans. Sorting is a method of arranging data items in any order.
2) What is searching?
Ans: It is a process of locating an element stored in a file.
3) Mention the different structured programming constructs.
Ans: a. Sequence
b. Selection
c. Iteration
4) What is stepwise Refinement?
Ans: Is a process of breaking down the problem at each stage to obtain a solutions.
5) Name the different searching methods.
Ans: a. Linear Search
b. Binary Search
s t
6) Define module.
Ans:
.h o
It is an independent set of statements, which can be called in another program.
7) What is the main advantage of linear search method?
a re
Ans.
c
It is simple and useful when the elements to be searched are not in any definite order.
u
8) What is the other name of bubble sort?
Ans:
.e d
The bubble sort method is also called as sorting by exchange.
w w
9) What is structured programming?
w
Ans: It is a method of using the concept of sequence , selection , iteration and modularity.
10) Name the searching technique which requires sorted elements.
Ans: Binary Search.
11) What is top-down analysis?
Ans: Solving a problem by breaking it up into smaller parts is called as top-down analysis.
12) What is top-down approach called as?
Ans: Top-down analysis is also called as stepwise refinement
13) What is a module?
Ans: Each program segment is called a module.
5
II Two Marks Questions:
1) Give an example for top-down analysis.
AREA OF A CIRCLE
h o
exchanges. Continuing the analysis we observe that as the iterations or passes increases the
.
comparisons and exchanges increases. Finally the total number of comparisons will be equal
to
a
1 + 2 + 3 + …….. + ( N -3 ) + ( N- 2) + ( N -1 ) re
= ( N ) * ( N – 1) /2
u c
= O ( N2 )
.e d
4) Explain any two properties of top-down approach
Ans: a. Code reusability
b. Program maintenance
w w
w
5) What are the two objectives of sorting process?
Ans: a. The movement of data should be as minimum.
b. Te data should be retained in the main memory.
6) Analyze the bubble sort method of sorting data
Ans: a. The first pass results in N-1 comparisons.
b. The second pass results in N-2 and worst case results in N-2 exchanges. Continuing the
analysis we observe that as the iterations increases the comparisons decreases.
= ( N-1 ) + ( N - 2 ) + ( N – 3) + . . . . . +2+1
= N * (N -1) / 2
= O( N2)
7) Analyze the selection sort method of sorting data
Ans: a. The first pass results in N-1 comparisons.
b. The second pass with N-2 comparisons. We observe that as the iterations or passes
increases the comparisons decreases.
= ( N-1 ) + ( N - 2 ) + ( N – 3) + . . . . . +2+1
= N * (N -1) / 2
= O( N2)
8) What are the advantages of structured programming?
Ans: a. Structured programs are easy to write as the programming logic is well organized.
6
b. Structured programs are easy to test and debug.
III Five Marks Questions and Answers:
1) Mention the objectives of structured programming.
Ans: a. To produce error free program.
b. To incorporate basic structured constructs.
c. To eliminate use of GOTO Statements.
d. To obtain a disciplined approach towards programming.
e. To improve the flexibility of a program.
2) Explain top-down analysis with an example.
Ans: The approach of dividing a problem into sub problems and dividing the sub problems
until a solution is obtained is called top-down analysis.
Ex:
SIMPLE INTEREST
s t
P T R SI ← ( P * T * R )
100
SI P T R
.h o
3) Write an algorithm to sort an elements using Insertion Sort.
Ans: Algorithm for Insertion sort
a re
Step 1 : START
u c
Step 2 : Input N
Step 3 : for I← 0 to N -1
Read A [ I ]
.e d
( end of I for loop )
w
Step 4 : For I ← 1 to N -1 Do w
Step 5 : J = I
w
Step 6 : While ( J > = 1 ) and ( A[ J ] < A [ J -1 ] )
Step 7 : TEMP = A [ J ]
Step 8 : A [ J ] = A [ J - 1 ]
Step 9 : A[ J - 1 ] = TEMP
Step 10 : J = J - 1
[ end of While loop ]
[ end of step I For loop ]
Step 11 : for I ← 0 to N -1
Step 12: Print A [ I ]
Step 13 : Stop
7
Pass 1:
A[1],A[0]>16,20,4,3
Pass 2:
A[2],A[1]> 16,4,20,3
A[1],A[0]>4,16,20,3
Pass 3:
A[3],A[2]> 4,16,3,20
A[2],A[1]>4,3,16,20
A[1],A[0]> 3,4 16,20
20 50 10 10 20 05
10 10 50 05 05 20
05 05 05 50 50 50
8
Pass 2 : 3 3
16 4
4 16
20 20
Pass 3 : 3 3
4 4
16 16
20 20
Sorted order is 3 , 4 , 16 , 20
w
Step 16: Print A[ I ]
Step 17: Stop
w
w
6) Explain Binary search algorithm
Ans: This algorithm is used to search for an element in a sorted list. The value of the element in the
middle of the list is compared with the value of the element to be searched for . If the middle
element is larger, the desired element has to be in the upper of the list. If the middle element is
smaller, the desired element has to be lower half of the list. The number of elements to be
searched is reduced by half in every iteration.
7) Write the steps involved in performing binary search operation to search an element 56
in the following numbers.
32 48 56 79 82 99
Ans: a. 32 48 56 67 79 82 99
0 1 2 3 4 5 6
Assuming ‘ a’ is the name of the array
s t
initial values:
.h o
n=7
low = 0
a re
high = n – 1 = 6
u
mid = [ low + high ] / 2 = ( 0 + 6 ) / 2 = 3c
S = 56 [ search element ]
a [ mid ] = 67
.e d
w w
Step 1 : Compare the element in a [ mid ] and search element 56
67 is not equal to 56
w
Step 2 : Check whether search element comes after or before the mid index element
Since 56 < 67 [ The search element is lesser than 67 , then the search element lies to the left
of mid point ]
Step 3 : Change high = mid – 1 = 3 – 1 = 2
mid = ( low + high ) / 2 = ( 0 + 2 ) / 2 = 1
Step 4 : Compare a [ mid ] and S for equality
Step 5 : Since 56 is greater than 48 [ If ( S > a [ mid ] ) i.e. 56 > 48 ]
Step 6: Change low = mid + 1 = 1 + 1 = 2
mid = ( low + high ) / 2 = ( 2 + 2 ) / 2 = 2
Step 7: Compare a [ mid ] and S for equality. Since S and a [ mid ] are equal search is successful
and the element is found at the location mid i.e. 2
10
8) Write an algorithm to find the maximum in an array
Ans: Step 1 : [Assume 1st element is the largest ]
large = A [ 0 ]
Step 2 : POS = 0
Step 3 : [ Find the largest element in the array and its position]
For I = 1 to N – 1 Do
Step 4 : If ( A [ I ] > large ) Then
Step 5 : large = A [ I ]
Step 6 : POS = 1
[ End if ]
[ End of step 3 for loop ]
Step 7: [ Print the largest and its position]
Print “ Largest = “ , large , “ position = “ , pos
Step 8: Exit
9) Write an algorithm to find the minimum in an array
u
Step 7: [ Print the smallest and its position]c
Step 8: Exit
.e d
Print “ smallest = “ , small , “ position = “ , pos
w w
10) Explain linear search method with an algorithm.
Ans: Step 1 : START
Step 2 : input N w
Step 3 : for I← 0 to N -1
Read A [ I ]
Step 4 : Loc = -1
Step 5 : For I = 0 to N- 1 do
Step 6 : If ( ele = A[I]) Then
Step 7: Loc = I
Step 8 : Goto step 9
[ end if ]
[ end for ]
Step 9 : If ( Loc > = 0 ) then
Step 10: Print “ ele Found in location “ , Loc
Step 11: else
Step 12: Print “ ele not found ”
Step 13 Stop
11
UNIT C-CHAPTER 3
C PROGRAMMING
ARRAYS
Questions carrying one mark:-
1) What is an array?
An array is a group of data of the same data type stored in successive storage
locations.
3)What is a subscript?
A subscript or an index is a positive integer value that identifies the storage position of
an element in the array.
s
5)How many subscripts does a one and two dimensional array have? t
h o
one dimensional array has one subscript and a two dimensional array has two
.
subscripts( row and a column subscript).
a re
syntax: datatype arrayname [size];
u c
6)Write the syntax for declaring a one dimensional array.
.e d
7) Write the syntax for declaring a two dimensional array.
w
Syntax: datatype arrayname [row size] [column size];
w
w
8) What do you mean by initializing an array?
Initializing of an array means storing data in to an array at the design time.
12
To print elements of an array a for loop is used.
Ex: int a[10];
For(i=0;i<10;i++)
Printf(“%d\n”,a[i]);
w
Ex: strlen(“ hello world”)=11
• strcat()- this function concatenates(combines) two or more stings in to a single
string.
strcat(str1,str2)
Ex: x=”beau” y=”tiful” strcat(x, y)=beautiful
• strrev()-this function reverses the string.
Syntax:strrev(str1)
Ex: strrev(“hello”)=olleh
• strcpy()-this function copies a string to a variable.
Syntax:strcpy(str1,str2)
Ex: strcpy(x,”moonlight”) x=”moonlight”
• strcmp()- this function compares the two syrings and returns the ascii difference
between the two strings. This is case sensitive.
Syntax:Strcmp(str1,str2)
Ex: strcmp(“their”,”there”)=-9
14
• strcmpi()- this function compares specified number of characters from both the
strings and returns a value. This function is case insensitive.
Ex: strcmpi(“There”,”there”)=0
.h o
• ispunct()- checks if a given character is a punctuation or not.
Ex: ispunct(‘?’)=true ispunct(‘ “)=false
a re
• islower()-checks if a given character is in lower case or not.
u c
Ex: islower(‘a’)=true islower(‘L’)=false
.e d
• isupper()-checks if a given character is in uppercase or not.
Ex: isupper(‘M’)=true isupper(‘h’)=false
w w
w FUNCTIONS
Questions carrying one mark:-
1. What is a function?
A function is a small segment of the program(sub program) designed to perform a
specific task and return a result to the main or calling program.
.e d
10. What is an argument?
w w
Information or values are passed to the function through special identifiers are called
arguments.
w
11. What are actual parameters?
The arguments (values) which are passed to the function when a function call is made
are called actual parameters.
16
14. How is a function invoked?
A function is invoked(or called) through an output statement or through an assigement
statement by using the function name followed by the list of arguments.
Ex: p = prod(x, y);
s t
17. What are local variables?
.h o
Variables declared inside a block or function are said to belong only to that block and
re
these are called as local variables. Values of these variables are valid only in that block.
a
18. What are global variables?
u c
.e d
Variables declared before the main function block are called global variables. Values
of these variables are available in every block of that program.
w w
19. What is function prototype?
w
A function must be declared before it is actually called. The declaration of a function is
known as function prototype.
17
sort(a, n); (where sort is the function name)
}
.h o
26 does Register variable have address?
Ans: No. (CPU registers do not have addresses).
a re
u c
TWO marks questions
.e d
w
Library functions w
1. Give the differences between library functions and user-defined functions.
User-defined functions
w
i. Some of the operations are i. Large programs can be broken down
programmed and stored in C library into smaller sub programs or modules.
so that they can be called in the These sub programs are called user-
program. These functions are called defined functions.
as library functions. ii. User-defined functions are created
ii. Library functions are in-built by the user.
functions.
18
3. Why is the return statement is required in a function body?
When a function is called control is transferred from the calling function (main
program) to the called function (sub-program). The statements of the called function are
executed and finally the called function is terminated and sends the required result back to
the calling function. The return statement is used to send the result from the function to the
main program, thus terminating the called function.
The syntax is: return;
Or
return(expression);
The first form does not return any value, where the second function returns the
value of the expression.
.e d
A user defined function may appear before or after the main() function. The general
w
syntax of function definition is as follows:
w
w
Return_type_ specifier Function_name (type arg1, type arg2….)
{
local variable declarations; argument list
statement1;
statement2;
… Body of the function
statement n;
return (expression);
}
Return data type- indicates the data type of variable sent back from called
function to calling function
Function name- indicates the name of the function .It is an identifier
Argument list- list of input variables and their datatypes received from calling
function
19
Local variable declaration-list of data that required only for the function block in
which they are declared.
Body of the function-It includes declaration part (local variables) and a set
of executable statements which will perform the required task.
Return statement- indicates termination of function and transfer of control from called
function to calling function
Ex:
int sum(int a,int b)
{
int c;
c=a+b;
return(c);
}
s t
2. Mention different types of functions. Explain any one(or any specific type may
be asked)
.h o
The different types of functions are
a re
Note: The explanation should include syntax and example
c
1. functions with no input and no return value
u
.e d
2. functions with input and no return value
3. Functions with input and return value
4. Recursive functions
w w
w
1. functions with no input and no return value- In this type of functions ,the user
defined function does not receive any input and does not send back any result to the
calling function.
Syntax:
20
Calling function ACTION Called function
{ {
..……..; ……………;
F1(); ………………;
……….; return;
Ex:
void main()
s t
{
void msg();
.h o
msg();
a re
}
u c
msg()
{ .e d
w w
printf(“hello world\n”);
}
w
2. functions with input and no return value- In this category of functions, the called
function receives one or more input values, but does not send any output(return
value) to the calling function
Syntax:
21
Callin function ACTION Called function
{ {
..……..; ……………;
F1(a,b); ………………;
……….; Return;
Ex:
void main()
{
s t
void sum(int,int);
int a,b;
.h o
scanf((“%d%d”,&a,&b);
sum(a,b);
a re
u c
}
Void sum(int p, int q) .e d
{
w w
int r;
r=a+b; w
printf(“sum of two numbers=%d\n”,r);
return;
}
3. functions with input and return value- In this category of functions ,the called
function receives one or more inputs and sends a return value to the calling function
Syntax:
22
Callin function ACTION Called function
{ {
..……..; ……………;
X=F1(a,b); ………………;
……….; Return(v1);
Ex:
void main()
{
s t
int sum(int,int);
int a,b,X;
.h o
scanf((“%d%d”,&a,&b);
X=Sum(a,b);
a re
u
printf(“sum of two numbers=%d\n”,X);c
.e d
}
w w
w
int sum(int p, int q)
{
r=a+b;
return(r);
}
Example:
void main()
{
int fact(int);
int n;
scanf(“%d”,&n);
printf(“factorial=%d\n”,fact(n));
getch();
}
int fact(int m)
s t
{
.h o
if(m==0)
return(1);
a re
else
u c
}
return(m*fact(m-1));
.e d
w w
w
3. Define the following a)Actual parameters b)formal parameters c)global
variables d)local variables
Actual parameters
When a function is called from main program(calling function), the function
call contains a list of data(variables) that are sent as input to the called function.
Such data are called as actual parameters or actual arguments.
Ex:
X=test(p,q,r);
p,q,r are actual arguments
Formal parameters
The function header of a called function contains a list of data along with their data
24
types. This list of data are known as formal parameters. The formal parameters
receive their value from actual parameters.
o The formal parameter values are available only as long as the function is
being executed.
o For every actual argument there must be a formal argument of the same data
type.
o Any changes made to the formal parameters in the called function do not
change the actual parametersOnce the function is terminated the formal
parameters are not available any more.
Ex: Int prod(int m, int n) function header
Local variables
Local variables are the data declared within a user defined function and available only
within that function.
Ex:
int sum(int a, int b)
{
s t
int r;
.h o
…………
………..
a re
u c
}
.e d
w w
Global variables
w
Global variables are the data that are declared before the main program and that are
available to the main program as well as the functions that are called from the
main program.
int p,r;
void main()
{
4. What are storage classes? Mention different types of storage classes. Explain
A storage class refers to the scope of data in a program. Scope of data means the
25
portion of the program in which the variable is valid(mian() as well as sub
programs) and lifetime of the variable.i.e., the length of time to which the variable
retains its value.
a re
External storage class
u c
.e
Keyword extern precedes the declaration
d
External storage class is similar to global variables.
Ex:
w w
w
Extern int m,n;
• Scope of the variable is global
• The variables are stored in memory
• Needs explicit(must use the keyword)declaration
• Initial value stored is junk
Register storage class
Register storage class is used when data is needed in cpu registers
Key word register must precede the declaration
Ex:
register int x,y;
• Scope of the variable is local
• The variables are stored in registers
• Needs explicit declaration
• Initial value is not known
26
Static storage class
Static storage class is used in function blocks. The static variable can be initialized exactly
once when the function is called for the first time. For subsequent calls to the same
function, the static variable stores the most recent value.
Key word static precedes the variable declaration
Ex: static int x,y,z;
POINTERS
Questions carrying one mark:-
1) What is a pointer?
s t
A pointer is a dynamic variable that stores address of a data value in a program.
2) How is a pointer declared in a c program?
syntax: datatype * pointer name;
.h o
Ex: int *p1,x=230;
a re
3) Name the operators used in pointers?
* and & operators
u c
e d
4) How is a pointer initialized . give an ex.
.
Initializing a pointer means storing the address of the data variable in to a pointer.
Ex: p1=&x;
w w
5) What is meant by a pointer to an array?
w
A pointer to an array stores address of the 1st data element of the array.
Ex: int *p1,a[4];
P1=a; or p1=&a[0];
6) If ptr is a pointer to an integer what is the meaning of an expression ptr++; ?
ptr++; will increment the pointer and will make the pointer store address of next data
element in the array.
7) What is meant by an array of pointers?
An array of pointer means a pointer array where every individual data is a pointer
variable that holds an address.
Ex: int*p1[10],a[10],b[10],c[10];
P1[0]=&a[0];
P1[1]=&b[0];
P1[2]=&c[0];
8) Is it possible to add two pointers?
no.
27
Question carrying two marks:-
1) With an example discuss the operators used with pointers.
• * indirection operator. This operator is used to declare a pointer.
• &- address operator. This operator is used to locate the address of a pointer.
EX: int x=245,*ptr;
Ptr=&X;
¾ Ptr- stores address of X
¾ X-value stored=245
¾ &X-address of X
¾ *ptr- contents of location whose address is stored in ptr(245)
¾
s t
It is not possible to perform arithmetic operations such as addition(+), subtraction(-),
multiplication(*), division(/) with pointers.
.h o
Questions carrying 5 marks:
re
1) Explain call by value and call by reference with example.
a
u c
call by value- when a function call is given, a relationship is established between
.e d
actual and formal parameters. A temporary storage is created for formal parameters to
store the data(actual parameters) received as input from calling function. This process of
{ int a=20,b=30,x;
Int f1(int,int);
w
-----
X=f1(a,b);
-----
Getch( );
}
Int f1(intp, intq)
{
p=p+p;
q=q+q;
return(p+q);
}
Call by reference- when a function is called, the address of variables are passed on to the
called function. The parameters receiving the address should be pointer variables. This
concept of sending the address of data from calling function to pointer variables in the
called function is known as call by reference.
28
Ex: viod main()
{
int a=10,b=15,c=20;
------
X=f1(&a,&b,&c);
------
getch();
}
int f1(int*p1, int *p2, int *p3)
{
*p1=*p1+10;
*p2=*p2+5;
}
s t
.h o
STRUCTURES AND UNIONS a re
Questions carrying one mark
u c
1) What is a structure?
.e d
A structure is a group of data of different data types.
w w
2) What is meant by structure template?
A structure template contains definition of a structure name and a list of members
along with datatypes.w
3) What is meant by structure declaration?
Declaration of a structure means memory storage is allotted to every structure
variable.
4) Which operator is used to access the structure elements?
dot (.) operator
5) Write the syntax for structure definition
syntax:
struct structurename
{
Datatype member1;
Datatype member2;
…………………….
};
6) Write the syntax for structure declaration.
syntax: struct structurename v1,v2,v3…..;
29
7) Which is the reserved word which is used in structure definition ?
struct
8) What are unions?
A union is a group of data of different data types all of which share a common
storage location.
9) Write the syntax for union definition declaration.
syntax: union unionname
{
Datatype member1;
Datatype member2;
……………………;
};
10) Write the syntax for union declaration.
=: syntax: union union name v1,v2,v3,……;
Int day;
Int month;
Int year;
};
Struct student
{
Int reg no;
Char name[20];
Struct dob date;
}s1;
30
3) What is meant by an array of structures?
An array of structures contains data elements of every structure variable stored in to an
array.
Ex: struct student
{
Int reg no;
Int age;
Char name[20];
}s[15];
Structures Arrays
1) Definition and declaration of program 1) Definition and declaration of
in structures are different. program in arrays are the same.
2) a structures is a group of data of 2) An array is a group of data of
different data types.
3) Nested structures are also accessed in
same data types.
s t
3) No nested arrays are used in
structures.
4) Structure members are accessed by
arrays.
.h o
4) Index is used to access data in
using dot (.) operator.
5) In structures, we use a reserved word re
arrays.
a
like struct.
u c 5) In arrays, we do not use any
reserved word.
.e
2. Explain structures with an example
d
w w
A structure is a group of data of different data types. A structure must be defined before it
is declared. A structure template is created during structure definition. Once the definition
w
is given, structure may be declared. Memory is allotted to a structure only after
declaration.
Syntax for structure definition:
struct structurename
{
Datatype member1;
Datatype member2;
…………………….
};
Example for structure definition:
Struct student
{ int regno;
Char name[20];
Int age;
};
Syntax for structure declaration:
Struct <structurename> v1,v2,v3,……..;
31
Ex: struct student s1,s2,s2;
To access the members of a structure .(dot) operator is used
Ex:
Scanf(“%d%s%d”,&s1.regno,s1.name,s1.age);
FILES
Questions carrying one mark:-
1) What is a file?
A file is a collection of data that is available in permanent storage.
s t
4) Write the syntax to open a file.
.h o
syntax: filepointer=fopen(FILENAME,MODE);
Ex: fp=fopen(“in.dat”,r);
a re
u c
.e d
w w
5) What is the significance of fclose() function?
This function closes a file that has been opened for an operation. Syntax:
fclose(filepointer);
Ex: fclose(fp);w
Question carrying 5 marks:-
1) Explain the different modes in which a file can be opened.
(write any 5 when the question is asked for 5 marks)
32
Mode Action
1)r 1)opens a file for reading
2)w 2) opens/creates a new file for writing
3) opens a file for appending data or
3)a creates a new file
.h o
a re
u c
.e d
w w
2) Explain the following functions in a c program fscanf(), fprintf(), fgets(), fputs(),
w
fread(),fwrite(), feof()
fscanf()- This function is used to read data from a file.
Syntax: fscanf(filepointer,”format specifier”,&v1,&v2,….);
Ex: fscanf(fp,”%d%d%d”,&a,&b,&c);
33
fread()- this function is used to read data into a structure from a file.
Syntax:
fread(&structure varable,size of(struct structurevariable),1,filepointer);
Ex: fread(&s,size of(struct s),1,fp);
feof()- this function returns a value true or false. When a file is being read, if there is no
more data in the file, then feof() function returns a value true. When a file is being read, if
there is more data in the file then the function returns a value false.
*********************************************************
What is Data?
s t
.h o
Data is the basic element in any computer processing. Data is a raw (unprocessed) fact or collection of
facts and figures or an observation. It may be number, an alphabet, or a sequence of characters.
For example 25, A, Sanjana etc.
a re
What is Information?
u c
Information is a processed data and has an implicit meaning. Information is a structured data. It is useful
for decision making.
.e d
Explain types of Information.
w w
1.
2.
3.
w
Strategic information
Tactical information
Operational information
4. Statutory information
1. Strategic Information:
• It is needed for long-term business goals and objectives.
• This directs the prospects of the business.
• Organizations aim for expanding their business, increasing the sales and profits, enhancing their
customer base, building their band, and grabbing the market capital.
• The marketing team observes the trends of the business and collects the sampling data and arrives
at strategic information.
2. Tactical Information:
• This type of information is needed for short term business goals and objectives.
• This information helps managers to make valid decisions to run the business efficiently and
effectively.
• In a small business organization, information on fast moving goods may be used to make tactical
decisions. Tactical information is obtained from the day-to-day transactions.
34
3. Operational information:
• It is required for daily business operations. Such as list of items which is out of stock. This
information can be used to trigger the purchase department to purchase those items and fill in the
inventory.
Eg : The information like list of customers who have not paid even after the
due date would be used to send the remainders.
• Operational information is obtained from the data processing group in the organization.
4. Statutory information:
• This information is provided by the Government as the regulation to be followed by the
organizations.
• Organizations must communicate to the government authorities about the results of their revenue,
profit and stock holder benefits such as dividend and bonus.
• The data processing system would provide the required information.
•
decisions.
s t
It helps the organizations in managing the resources effectively and efficiently.
•
.h o
What is data Processing System?
a re
u c
A system which includes the resources such as people, procedure and devices that are used to
accomplish the processing of data for producing desirable output
.e
Explain Data Processing Stages /cycle: d
Organization
w w
w
Input Storage
Output
Report
1. Data collection
2. Data preparation
3. Data entry
Data Collection:
Data Preparation:
• Is a process of creating the documents for further processing. In this step, the data collected is
put into a data sheet.
s t
Data entry:
.h o
• Is a process of entering data into the computer for data processing. The data may be entered into
character recognizers.
a re
the computer through various input devices such as keyboard, optical scanners or magnetic
c
• Eg: To generate marks report of the student, collect roll-no, name, each subject marks
u
Processing:
.e d
w
The data entered has to be processed. This process involves the following five steps.
w
1.
2.
3.
Storage
Retrieval w
Categorization
4. Organization
5. Updation
1. Storage: is a computer memory where data is stored permanently for future processing. The
data may be stored on a magnetic tape, hard disk or optical disks.
2. Retrieval: is a process of getting the desired data from storage. There are a set of commands
which will help accessing memory and fetching data for processing.
3. Categorization: is a method, which classifies data into most recent and least recent data. The
data can be old or new.
36
i) When a new batch of students get admitted to the course, data pertaining to this batch is added
to the student information system and when someone discontinues the course, his/her records are
deleted from the system.
ii) To generate marks report, to calculate total, average, grade etc.
Output:
This is the process of getting the results printed on paper. (Printout)
The printout can be obtained in the following 2 steps.
1. Report generation
2. Inquiry generation
Report generation:
Is a process of providing the hard copy output.
For eg: after the examination, the results can be printed on paper.
Inquiry response:
is a process of providing an individual report on inquiry.
For eg: Inquiry about those students who have got distinction, first class, second class and so on.
s t
Files and File organization:
.h o
re
Files are the backbone of any data processing and database management system. They are used to store
business data and records.
a
u c
.e
Record: is a collection of related data fields. d
Data file: is a collection of logically related records.
What is database? w
A database is a collection of logically related data
1. File creation
2. Location a record
3. Adding a record
4. Deleting a record
5. Modifying a record
Types of Files:
• Master file
• Transaction file
Write the difference between Master file and Transaction File
37
Master File Transaction File
1) The data stored in these files are 1) The data stored in these files are
permanent by nature temporary by nature
2) This file is empty while nature 2) This file contains data only for period of
time and send to the master file
3)This files are updated only through recent 3) Any data to be modified is done in this
transactions file
4) This file stores large amount of data 4) In this file the data to be modified is
Eg: customer ledgers, student database stored . Eg: price of the products,
customers order for the products, inserting
new data to the database etc.
FILE ORGANIZATION:
It refers to the way of arranging the records in a file which can be accessed in a faster way.
. The criteria considered in choosing a file organization are:
1) Fast access to single record or collection of related records.
2) Easy record adding/ update/ removal without disrupting.
3) Storage efficiency
4) Redundancy as a warranty against data corruption.
s t
The files are generally viewed as
h o
• Logical File organization: The groups of fields which are combined to form logical
.
•
a re
record, which can perform different operations on the file.
u c
Physical file organization: The data which is stored in the form of records can be
placed in any storage devices, main memory, secondary memory etc.
w
2) Direct Access File Organization
3) Index Sequential Access File Organization
Advantages:
1) Simple to understand
2) Easier to organize, maintain
38
3) Economical
4) Error in files remain localized
Disadvantages:
1) Entire file has to be processed
2) Transactions must be sorted in a particular sequence before processing
3) Time consuming searching
4) High data redundancy
5) Random enquiries are not possible to handle
Advantages:
1) Immediate Access of the desired records.
2) No sorting of the records is required.
s t
3) Faster updating of several files.
.h o
4) Helps in online transaction processing system like online reservation systems.
Disadvantages:
a re
2) Backup facility is needed
u c
1) Data may be accidentally erased or over-written unless special precautions are taken
.e d
3) Expensive- hard disks are needed to store the records, it is expensive
4) Less efficient as compared to sequential file organization in the use of storage space
5) Only one key is used
w w
6) Cannot be accessed sequentially
w
Index Sequential access file organization(ISAM)
1) This file organization is a synthesis of the above two file organizations.
2) It combines the positive features of both the sequential and direct access file organizations.
3) Here records are stored randomly on a direct access device such as magnetic disk by a primary key.
Hence, we can access data either sequentially or randomly using the index. The index is stored in a
file and read into memory when the file is opened.
4) It may have multiple keys. These keys can be alphanumeric
5) The key upon which the data records are ordered is called the primary key.
6) Other keys are called alternate keys
Advantages:
1) Multilpe keys – are also alphanumeric in nature
2) Both sequential and random access is possible
3) Accessing of records is fast, if the index table is properly organized
Disadvantages:
1) More storage space is needed because of the presence of Index
2) Less efficient in the use of storage space as compared to other file organizations
3) It requires special software, i.e expensive.
39
DBMS
What is DBMS?
DATABASE MANAGEMENT SYSTEM is a software used for management, maintenance
and retrieval of data stored in a database.
Eg : Oracle, MS-Access, Sql server etc.
a re
c
Write the difference between Manual Data and Electronic Data Processing.
u
Manual Data Processing
.e d
Electronic Data Processing
1) The volume of the data processed is 1) The volume of the data processed is
limited in a desirable time
w
2) Use of large amount of paper w unlimited
2) Automation -Eliminates the use of
4) High cost
w
3) The speed and accuracy is limited
papers to solve problems
3) High speed, greater accuracy
4) Reduced cost
5) Repetitive tasks reduces the efficiency of 5) Never gets tired
a human being
6) The amount of data, which can be 6) The amount of data, which can be
stored, accessed or processed is limited stored, accessed or processed is unlimited
40
MS-Excel
a re
c
Explain briefly any two-built in functions in spreadsheet.
u
Ans: (Write any two)
.e d
SUM(range) : this function returns the sum of all the numbers
w w
in the list of arguments.
Example: =SUM(A2:E2)
w
ABS(number) : It returns absolute value of a number.
Example: =ABS(-35)=35
SQRT(number) : This function returns a positive square root.
Example: =SQRT(5) equals 2.1928.
AVERAGE(num 1, num 2……) : Returns the average of the set of numbers.
Example: =AVERAGE(15, 25, 50) returns 30.
re
iv. Sorting: The data can be arranged in a specific order in a table.
a
u c
Ans:
.e d
Explain any two Logical functions in Ms-Excel.
w w
1. AND(logical1, logical2………) : This function returns TRUE if all its
w
arguments are true, returns FALSE if one or more arguments are FALSE.
Example: =AND(3<5, 8=8) returns TRUE
=AND(3>5, 8=8) returns FALSE
2. OR(logical, logical 2………) : It returns TRUE if one or more arguments are
TRUE, returns FALSE if all its arguments are FALSE.
Example: =OR(3<5, 8<>8) returns TRUE
=OR(3>5, 8<>8) returns FALSE
3. NOT(logical) : Reverses the value of its arguments.
Example: =NOT(3<5) returns FALSE
=NOT(3>5) returns TRUE
4. If(logical-test, value1, value2) : It returns value1 if logical test is true. If logical test is
false it returns value2.
Example: =If(85>80, “Dist”, “I Class”) returns “Dist”
=If(40>50, 100, 200) returns 200
42
SQL (Structured Query Language)
Expand SQL.
Ans: SQL stands for Structured Query Language.
Expand DDL.
Ans: DDL stands for Data Definition Language.
Expand DML.
Ans: DML stands for Data Manipulation Language.
s t
What is meant by DML?
.h o
Ans: DML is a language used for retrieval of data, insertion of new data and deletion or
modification of existing data.
a re
u c
What is the SQL command for creating database?
Ans: create table;
.e d
This command is used to create a table in the database.
w w
Name the SQL command for deleting tuple from the database.
w
Ans: Delete from tablename where condition;
This command is used to erase certain unwanted rows from the table.
Name the SQL command for inserting tuple from the database.
Ans: The insert command is used to insert one or more rows (new records) to an existing
table.
What is structured Query Language? Write the SQL command for deleting
tuple(row) from the database.
Ans: SQL is a relational database language designed and developed
43
to create a database, delete, update or retrieve data from a
database.
The delete command is used to erase certain unwanted rows from the table.
Example:
Insert into student values(145, ‘Kumar’, ‘I PUC’, ‘PCMC’, 4500.00)
Write the syntax and example for deleting a table using DROP.
Ans: Drop command is used to remove unwanted tables from the database.
Syntax: Drop table tablename;
44
UNIT E
Fundamentals of Network operating system
Question carrying 1 marks :-
1) What is a computer network?
It can be defined as interconnection of autonomous computers and terminals
together using communication systems to facilitate exchange of information.
2) Mention the advantage of networking.
speed, cost, etc
3) Mention the different types of network.
Local area network(LAN),
Wide area network(WAN),
Metropolitan area network(MAN)
4) What is a file server?
It is the main component of the network. It is a very fast computer with a large
amount of RAM and storage space. File server stores all the files and
application software and operating system.
5) What is a work station?
s t
It is also referred to as nodes, clients are the computers connected to the file
server.
6) Mention the most widely used interface card. .h o
Ethernet cards
a re
7) What are routers?
u c
a router translates information from one network to another. Routers select the
e d
best path to route a message based on the destination address and origin.
8) What are switches? .
w w
it is a device that provides a central connection point to cables from server’s
w
workstations and peripherals.
9) What are the functions of the bridges in the network?
It provides link between the older network and the new network.
a re
In this architecture all computers are considered equal because all have the
u c
same abilities to use the resources available on the network. Here the resources
5 mark questions
.e d
are shared among the nodes. Each computer acts both as client and server.
w w
1. Explain advantages of Computer Network
• Speed: The files can be transferred from one Computer to another instantly.
w
• Cost: Application software(Network version) can be installed on one Computer and
accessed by other Computers on the Network. This makes maintenance and
upgrading of software easy.
• Security: The information on the computer can bemade available only through
password.Further some information can be made available only for reading and
not copying.
• Easy access: Users can access information from any computer that is available on
the network. They need go to a specific Computer which may be located in a
different building or different location to retrieve information from their account.
s t
• File Services-All the data files of an organisation are stored in one place and can be
.h o
shared by many users. Files can be organised and updated systematically.
re
• Print Services- When Printers available on the Network , multiple users can print to
a
the same printer. The network printers are usually faster and more capable. They
u c
may have accessories such as envelope readers or multiple paper trays
.e d
• Database Services-Multiple users can have access to the database at the same time.
w
The Database software ensures integrity of data and provides multiple access.
w
w
• Message Services-The services include Electronic mail, voice mail, remote
access,document transfers across the internet.
47
STAR- in star network, each node is connected directly to the central computer. All
communications between the nodes have to pass through the central computer. Star
networks allow the administrator to give selected nodes higher priority and also allow
centralized running of diagnostic programs.
RING- in a ring network, all nodes are connected to a common cable, and the cable
starts and ends at the network server. In this type of network, communications are
always in one direction, and the data being transmitted is passed through each node in
the ring. A major disadvantage of this network is that when a node fails, it can
completely halt all communications on the network.
TREE- a tree topology combines characteristics of linear bus and star topologies. It
s t
consists of groups of star configured workstations connected to a linear bus backbone
cable. Tree topologies allow for the expansion of an existing network, and enable
schools to configure a network to meet their needs.
.h o
MESH- a pure mesh network has point- to- point connections between every node in
re
the network. Pure mesh architectures are not usually considered practical. One problem
a
c
is that each device requires an interface for every other device on the network.
u
.e d
w w
5. Write short notes on Client-Server networking
w
Client -server networks consist of servers and clients. Server is a powerful Computer
using advanced network operating system and clients(works tation) access data stored in
servers. Server can host e-mail, store common data files and other applications needed by
the client. The server also validates any user who tries to login and denies access to
network resources as well as client software to unauthorised users. Servers are mainly
used for centralised management of data and resources.
Advantages
• Data security and resources are controlled through server.
• Upgrading and replacement of applications are done as needs increase, without
changing the existing formats.
• Clients can access the server from remote locations.
• Reduces cost of client’s computer
• New technologies(object oriented programming)can be integrated easily ,as and
when the need arises.
48
Limitations(Disadvantages)
• Initial investment may be expensive
• Maintenance will require staff who must ensure efficient operations
• If the server breaks down , the operations of client processes may stop.
Advantages
• There is no need for dedicated server. Therefore less expensive.
• A single user operating system such as windows-XP is sufficient
Disadvantages(Limitations)
s t
• There can be no security as all computers can be accessed by all users
h o
• A failure of a node in peer-peer network means the network can no longer access
.
data or applications on that node.
a re
• The number of Computers connected are limited to 10 or 12
u c
7. Explain features of Windows operating system
e d
¾ Windows operating system is GUI (graphical user interface)based
.
w w
¾ Built in support for multiple users on a single PC
¾ Plug and play support for hardware
w
¾ User friendly interface
¾ Uses device driver software for easier installation of new hardware and software
Note : to write the features of windows NT(Network operating system) same features can be high
lighted. In addition to this the following points may be added.
• Supports client-server applications
• Management of networks
49
• Wide range of support tools are available such as debugging tools,compilers and
other software.
• Hierarchial directory structure for maintenance of directories and files
s t
****************
.h o
a re
u c
.e d
w w
w
50