SECTION A QUES 1- WHAT DO YOU MEAN BY OPERATING ...

feastcanadianΛογισμικό & κατασκευή λογ/κού

14 Δεκ 2013 (πριν από 7 χρόνια και 10 μήνες)

353 εμφανίσεις

SECTION A

QUES 1
-

A
-

WHAT DO YOU MEAN BY OPERATING SYSTEM?EXPLAIN FUNCTIONS PERFORMED BY AN
OPERATING SYSTEM.


ANS
-
Operating system is a system software that is requird for a computer to become functional and
operational. It provides functionality to computer hardware so that electro mechanical devices of it

perform read,write,and processing functions as human bei
ngs do.


Without operating system ,computer cannot work .in the absence of operating system, neither input
devices will be able to provide data to the computer nor memory will be able to process the data nor
will output devices be able to show the result.

Managing computer’s resources and making them work in co
-
ordination with each other is the
responsibility of operating system.

Functions of Operating System

The most operating systems perform the following important functions:

1.
Processor management,

t
hat is, assignment of processor to different tasks being performed
by the computer system.

2.

Memory management,

that is, allocation of main memory and other storage areas to the
system programs as well as user programs and data.

3.
Input/output management
, that is, co
-
ordination and assignment of the different output and
input device while one or more programs are being executed.

4.
File management
, that is, the storage of file of various storage devices to another. It also
allows all files to be easily ch
anged and modified through the use of text editors or some other
files manipulation routines.

5.
Establishment and enforcement of a priority system.

That is, it determines and maintains the
order in which jobs are to be executed in the computer system.

6.

Automatic transition from job to job
as directed by special control statements.

7.
Interpretation of commands and instructions.


8.
Coordination and assignment of compilers, assemblers, utility programs,

and other software
to the various user of the compu
ter system.

9.
Facilities easy communication between the computer system and the computer operator
(human). It also establis
hes data security and integrity



TYPES OF OPERATING SYSTEMS


Various types of operating systems are
available for use,forexample,MS
-
DOS,WINDOWS,Linux,Unix etc.



B
-

DIFFERENTIATE SYSTEM SOFTWARE AND APPLICATION SOFTWARE.

ANS
-

SYSTEM SOFTWARE
-


All those instructions,when computer uses either for its activation or internal resourse
managem
ent are called system software that is required for any computer to become operational.It
activates all its devices components and resourses and makes them ready for work.

Eg
-

windows ,linux,unix,etc

APPLICATION SOFTWARE
-

Those application ,which are
given to the computer for automating a manual task,are called application
software.Application software is either developed using special packages or special computer languages
that are developed for this purpose special software developments packages
.


Eg
-
MS
-
Office,coreldraw
,
photoshop,flash are application software.



QUES2
-

A
-


WHAT ARE STORAGE CLASSES? DEFINE WITH EXAMPLES.

ANS:

The storage class is another qualifier (:like long or unsigned) that can be added to a variable
diclaration as shown in:

Stor
age class Meaning

auto local variable known only to the function in which it is declared default




is auto.

Its default initial value is garbage value.


It is stored in memory


Eg
-

auto int cou
nt;


Static local variable which exists and c
ontains its value even after the control




Is transferred to the calling function
. Its default initial value is zero

. It is stored


In memory.


Eg
-

static int x;

extern global variable known to all funct
ion is the file.It is
also known as global


variable.

Default

initial value is zero.

It is stored in memory.


Eg
-

extern long total;

register local variable
which is stored in the register i.e.

known only to the function in


which it is declared.

Default initial value is zero.


Eg
-

register char ch;


B
-
WRITE A PROGRAM AND MAKE A FLOW CHART TOREAD TWO NUMBERS FROM THE KEYBOARD
AND SWAP THAT NUMBERS W
ITHOUT USING THIRD VARIABLE.

ANS
-

#include<stdio.h>

#include<wnio.h>

noid main()

{

inta,b;

clrscr();

printf(‘’Enter a and b’’);

scanf(“%d%d”,&a,&b);

a=a+b;

b=a
-
b;

a=a
-
b;

printf( “%d”,a);

printf(“%d”,b);

getch();

}

For flow chart contact room no.212


QUE
S 3:

A
-

WHAT ARE TRANSLATORS? WHY WE NEED THEM? EXPLAIN WITH REASONS.

ANS
-

Translators are softwares which convert high level language into machine language. It is essential
for effective communication between user and computer. Translator is designed for
each language. It
takes English like commands from us. Converts them in 0 and 1 equivalent form ,so that computer could
understand the command and execute it.

Two types of TRANSLATORs are available for this conversion
-
:

INTERPRETER
-

(i)
T
he software tha
t convert any computer program into machine language is called interpreter.

(ii)

It performs line by line conversion and gives the error at the end of each line.

(Iii)
It is a step by step approach for execution of program.

COMPILER
-

(i)

It reads all the lines
of program all together and converts them at once,

(ii)

It gives

all the errors at once at the end of program execution.

(iii)

It is a one shot approach translator.


B
-

WRITE A PROGRAM TO PRINT THE FACTORIAL OF A NUMBER.


ANS
-


#include<stdio.h>


#include<conio.h>

vo
id main( )

{

intf,i,n;

printf(“enter the no”);

scanf(“%d”,&n);

for(i=1;i<n;i++)

{


f=f*i;

}

printf(“the factorial is”,f);

getch();

}




QUES
-
4 :

A
-


DRAW THE FUNCTIONAL BLOCK DIAGRAM OF A DIGITAL COMPUTER AND DISCUSS ITS
COMPONENTS IN BRIEF.

ANS
-

Computer is an electronic machine which process the information according to set of
instructions(Program),does arithmetic and logical problems and gives the answers very quickly.

It is thus a programmable machine which reads the binary instructions and pro
cesses the data which are
presented in binary form. It has following units that work in coordination to perform some task
-
:

(i)
Input unit
-
those devices that take information from user

like keyboard,mouse,joystick,etc.

(ii)output unit
-
those devices that di
splay the results like printer,plotter,monitor,etc
.

(iii)Central Processing Unit (CPU)
-

It consists of following :


(a)
ALU
-
Arithmetic and Logical unit
. It performs all the mathematical calculations and logical
operations.


(b
)CU
-
Control Unit
: It keeps
control over all other components and sees that that work in coordination
and ensures movement of right data at the right time from right source to right destination.


(c)
GPR
-
General Purpose Register
: It temporarily stores data and intermediate results
while the
computer is making execution.


(d)
Accumulator
-

It is a register and contains one of the operands and stores result of arithmetic and
logical operations.

(e)
MU
-
Memory Unit
-

It holds data and instructions and is the memory box of computer.

Diagram

from class notes.

B
-
CONVERT THE FOLLOWING:

(i)

(1101101.101)
2
to octal

101
-
5

101
-
5

001
-
1 (155.5)
8

(ii)

(357)
8
to decimal

(3*8
2
)+(5*8
1
)+(7*8
0
)

=
192+40+7=

(239)
10




(iii)

(B678A)
16

to binary

B
-
1011


6
-

0110


7
-
0111


8
-
1000


A
-
1010


(1011011011110001010)
2


(iv)

(125)
10

to hexadecimal

= (7D)
16





QUES
-
5:

A
-

WHAT IS DATA TYPE? DEFINE ALL TYPES OF DATA TYPE SUPPORTED BY C LANGUAGE.

ANS:

Data types are the type of data availa
ble in C.

They are the means to identify the data &
associated problems of handling it.

C supports three types of data types:
-


(i)Primary (fundamental)datatypes
-

They are pre defined types supported by C.

They are given
below:

TYPES

SIZE(BYTES) RANGE

signed char 1
-
128 to 127

unsigned char 1 0 to 255

signedint

2
-
32768 to 32767

unsignedint 2 0 to 65535

signed short int 1
-
128 to 127

unsigned short int

1 0 to 255

signed long int 4
-
2147483648 to 2147483647

unsigned long int 4 0 to 4294967295

float

4 3.4E
-
38 to 3.4E+38

double 8 1.7E
-
308 to 1.7E+308

long double 10 3.4E
-
4932 to 31.1E+4932


(ii)Derived data types
-
They are

declared with the help of fundamental datatypes . They are
arrays,functions,structures.

Eg
-
intsq[25];

(iii)User
-
defined data types
-

They are defined by user.They are
typedef and enum.

Eg
-
typedefint units;

units batch1,batch2;


enumday{Monday,Tuesday,Thurs
day…..,sunday};

enumdayweekstrt,weekend;

weekstrt=Monday;

weekend=Friday;






B
-
DISCUSS ABOUT THE GENERATIONS OF COMPUTER ALONG WITH ITS ADVANTAGES AND
DISADVANTAGES.

ANS:


QUESTION NO.6
-

A).
Define meaning of break and continuity keywords in c with
examples.

Ans.

BREAK STATEMENT
-

The break comma
nd abruptly terminates the loop. A
s soon as it gets executed,program controls comes
out of the loop gets executed.

#include<stdio.h>

#include<conio.h>

void main()

{

int a;

printf("enter a");

scanf("%d",&a);

switch (a);

{


case 1:


printf("
\
n sunday");


break;


case 2:


printf("
\
n monday");


break;


case 3:


printf("
\
n tuesday");


break;


case 4:


printf("
\
n wednesday");


break;


case 5:


printf("
\
n thursday");


break;


case 6:


printf("
\
n friday");


brea
k;


case 7:


printf("
\
n saturday");


break;


default:


printf("wrong input");

}


CONTINUE STATEMENT
-

The continuity command,when executed breaks the current cycle of the loop and places the program
control at the end of the loop.Thus all the statement written after continue command,written the
loop,get bypassed in the current iteration.

#incude<stdio.h>

#
include<conio.h>

main()

{

int i,j;

float total=0;

for (i=1,i<7,i++)

{


for (j=1,j<7,j++)


{


if (i!=j)


continue;


else

{

total=total+pow(i,(j+1));

}

}

}


printf("
\
n sum=%g",total);

}

B).
Write a program in c language to generate the given series up to term

less than 200.1
-
4+9
-
16+25...........

Ans.
PROGRAM
-

#include<stdio.h>

#include<conio.h>

{

int a,sum ev,sum odd,total;

for(a=1;a<=200;a++)


{


if (a%2==0)


{


sum ev=sum ev+(a*a);


}


if (a%2!=0)


{


sum odd=sum odd+(a*a);


}


}


total=sum odd
-
sum ev;

printf("%d",total);

getch();

}





SECTION
-
B

QUESTION NO.7
-

A).
Define operator?How many types of operators are available in c programming? Explain any four of
them with examples.

Ans.
Operators are symbols whic
h performs several operations.

it shows the relation between the
operands.

It can be classified as:



Arithematic opreators (+,
-
,*,/,&,%)



Relational operators(<,>,==,>=,<=,!=)



Logical operators(&&,|| and!)



Increment (++) and Decrement(
--
)



Assignment
operators (=)



Conditional operators(? :) syntax (exp)?(exp):(exp)



Bitwise operators(&,|,^,>>,<<,~)



Special operators(*,&,size of ())

*ARITHEMATIC OPERATORS
-



integ
er



real



mixed
-
mode arithematic

eg
-
int a+b,float a/b.

*INCREMENT AND DECREMENT OPERATORS
-


Una
ry operators and they require variable as


their operands.

When post fix (++)or(
--
)
-
The expression is evaluated first using the original value of the variable and then
the variable is incremented or decremente
d.

When prefix
-
The expression is incremented or decremented first and then the expression is evaluated
using the new value of the variable.

eg
-
a+=,
--
a

*CONDITIONAL OPERATORS
-

In the below example x will be assigned the value of b.This can be get by if else

as

For example
-
if(a>b)


x=a;


else


x=b;


OR

For example
-
a=10


b=15


x=(a>b)?a:b;

*BITWISE OPERATORS
-

It is used to manipulate of data at
bit level.

& BITWISE AND

| BITWISE OR


^ XOR

-
1S COMPLIMENT

<<

BITWISE LEFT SHIFT

>>

BITWISE RIGHT

For example see D S yadav book


B).
WRITE A PROGRAM TO PRINT ALL PRIME NUMBER FROM 1 TO N TERMS.

Ans
.
PROGRAM
-

#include<stdio.h>

#include<conio.h>

void main()

{

int i,j;

clrscr();

scanf(“%d”,&n);

for(i=2;i<=n,;i++)


{


if (i%j==0)


{


break;


}


}


if (i==j)


{


printf("
\
n %d",i);


}


}

getch();




QUES
-
8

A
-

DEFINE ALGORITHM WITH ITS CHARACTERISTICS.DRAW A FLOWCHART OF FINDING THE
GREATEST NUMBER

AMONG THREE NUMBERS.

ANS:

Algorithm and its Characteristics

An algorithm is a method of representing the step
-
by
-
step procedure for solving a problem. An
algorithm is quite useful for finding the right answer to a simple or a difficult
problem by breakin
g it into simple cases.

The various characteristics that are necessary for a sequence of instructions to qualify as an
algorithm are:

• The instructions must be in an ordered form.

• The instructions must be simple and concise. They must not be ambiguou
s.

• There must be an instruction (condition) for program termination.

• The repetitive programming constructs must possess an exit condition. Otherwise, the program
might run infinitely.

• The algorithm must completely and definitely solve the given
problem statement
.


B
-

WHY IS C CALLED STRUCTURED PROGRAMMING LANGUAGE? EXPLAIN.

ANS
-


(i)
Structured programming is a subset of one of the key programming paradigms i.e. procedural
programming.

C follows a definite Top
-
down approach for this procedure.

(ii)
It helps in making a program easily understandable and debuggable. A p
rogram that is not
based on the
structured pr
ogramming approach is very diffi
cult to
maintain, debug and
understand.
Structured programming approach mainly focuses on the order of execu
ti
on of the
statements within a program.Therefore C has a hierarchial structure.

(iii)
It suggests the use of sequential execution of statements in a progra
m. Thus, structured
programming
approach suggests the use of mainly three types of control structures:

sequential,
repetitive and selective.
In C we have for looping for this.

(iv)C also provides if
-
else statements and switch case statements for test choice programming
and multiple choice structure

(v)
Further, it suggests avoiding the use of goto, break and

continue statements i
n a program as all
of these are
unconditional branch statements
.

(vi)C has a modular approach to make programming

easier and simpler.



QUESTION NO.9
-

B).
COMPARE DOS,WINDOWS AND LINUX OPARATING SYSTEM.LIST FIVE COMMANDS OF DOS AND
LIN
UX OPERATING SYSTEM.

Ans.
DOS
-

Unix is multi
-
user,multi
-
tasking and time sharing operating system.It was designed and
developed in between 1960 to 1970 by a group of AT &T employed at Bell Laboratories,It is a versatile
and standard operating system.It gai
ned its popularity because of its protasility and robustness.It is
popular till date.Its features provide easy to operate working environment.


LINUX
-

Linux is basically multi
-
user,multi
-
tasking operating system.It provides character user interface
and gr
aphical user interface both for interacting with computer.It was developed by Linux Benedut
Torvalds in 1991.

It has powerful networking features incorporated into it and has built in Internet facilities.It provides
both user interface CUI and GUI.

WINDOWS
-

It is the most popular operating system of modern times.It has been developed by
MICROSOFT CORPORATION of USA.It t not only activates computer and makes its devices functional,it
also provides application for performing wide variety of tasks on computer
.For notepad,paints etc.

It is GUI based operating system and multitasking operating system.

COMMANDS OF DOS
-

mv
-
renames directory d1 to d2

exit
-
terminates current session

mkdir
-
makes a new directory

rmdir
-
removes specified directory x if it is empty.

date
-
displays current system date and time.

COMMAND OF LINUX
-

mv
-
it moves a file from one directory to another

mkdir
-
it makes a new directory

rmdir
-
this command removes the blank directory

cd
-
using this command,user can move from one directory to another

c
p
-
it copies the contents of a file into another file








QUES 10:

A
-

DEFINE VARIABLE DECLARATION AND INITIALIZATION WITH THE HELP OF AN
EXAMPLE.

ANS
-

(ii) Initialization and Assignment

INITIALIZATION

is the process of allocating an initial value to a variable in a prog
ram. Each
variable in a program
must be initialized before it can be put to use.

DECLARATION
, on the other han
d is the process of assigning a
value to a variab
le as and when
the need ar
ises.

While INITIALIZATION happens only once in a program,

variable

DECLARATION

can happen multiple number of times. In other words, initializat
ion can also be
referred as the fi
rst time assignment of a variable.

Example

.

.

.

int a=10; //Initialization

.

.

a=20; //Declaration


B
-

WRITE A PROGRAM TO CHECK T
HAT A NUMBER IS AN ARMSTRONG NO.

ANS
-


.
#include<stdio.h>

#include<conio.h>

#include<math.h>

void main()

{

intnum,d,n,sum=0;

clrscr();

printf("enter the no");

scanf("%d ",&num);


n=num;

while(num!=0)


{


d=num%10;

sum+=pow(d,3);

num=(num
-
d)/10;


}

if(n==sum)


{


printf("the no. is armstrong");


}


else


{


printf("the no. is not armstrong");



}


getch();



}



QUES 11:

A
-

WRITE A PROGRAM TO DETERMINE IF A NUMBER IS ‘ODD’ OR ‘EVEN’
,without
using
ELSE option,
AND PRINT THE MESSAGE.

ANS:

#include<stdio.h>

#include<conio.h>

void main()

{

inta,I;

printf(“enter your no”);

scanf(“%d”,&a);

if(a%2==0)

printf(“even no.”);

if(a%2!=0)

printf(“odd no”);

getch();

}




B
-

COMPARE WHILE AND DO WHILE LOOP WITH
PROPER SYNTAX,FLOWCHART AND
EXAMPLE.

ANS
:
Difference between
While…
and
Do…While Loops

While… Do…While

(i)It is an entry
-
controlled loop.

(i) It is an exit
-
controlled loop.

(ii)In
while

loop, the test condition is (ii) the body of the loop is executed first

checkedfIrst and the body of the loop is executed only

and then the test cond
ition is checked to
determine
if the test condition is true.

If
th
e next iteration will be executed


.

(iii)The body of the loop may never get executed even once (iii)
The body of the loop will be executed

if the test conditio
n fails in its very fi
rst evaluation.
atleast once

even

if the test condition

fail

SYNTAX:

SYNTAX:


while(test condition) do

{

{


Do this;

do
this;


Increment operator;

and do this;

} increment

operator;



}

while(test condition);


Example Example

. .


. . .

. .

. .

int I

inti;

i=1;
i=1;

while(i<=10)

do

{

{

printf(“%d”,i);

printf(“%d”,i);

printf(“
\
n”); printf
(“
\
n”);

i=i+
1;

i=i+1;

}

}

.

while(i<=10);

. .

.






QUES 12:

A
-

WRITE A PROGRAM TO FIND THE ROOTS OF QUADRATIC EQUATION.

ANS:

#include<
stdio.h>

#include<conio.h>

#include<math.h>

void main()

{

float a,b,c,d,r1,r2;

printf(“enter a,b,c”);

scanf(“%f%f%f”,&a,&b,&c);

d=sqrt(b*b
-
4*a*c);

if(d>0||d==0)


{

r
1=(
-
b+d)/(2*a);


r2 =(
-
b
-
d)/(2*a);

printf(“roots are =%f%f”,r1,r2);


}

e
lse

p
rintf
(“roots are imaginary and unequal”);

getch();

}



B
-
WHAT IS THE USE OF SWITCH STATEMENT? WRITE THE SYNTAX AND EXPLAIN HOW IT IS
DIFFERENT FROM IF STATEMENT.

ANS
-

Use of switch statement:
The switch statement is particularly useful in situations where
decision
-
making is

to be performed on multiple alternative options. Such a situation can also be realized with the
help of nested

if
-
else blocks but such an approach is complex and error prone.

Syntax of switch statement:

switch (expression)

{

case value
-
1
:

block
-
1

break;

case value
-
2:

block
-
2

break;

..........

..........

default:

default
-
block

break;

}

statement
-
x;

Difference between switch and if statement:

(i)

A single if statement allows us to select only between two alternatives whereas switch
statement
allows theselection amongst multiple alternatives.

(ii)

A float expression cannot be tested using switch,whereas if can test float expression.

(iii)

In switch multiple cases cannot use same expressions.

(iv)

In switch case we can not use relational operator but in case of

if we can use.