Hamid

   
 
  CS-63.
Course Code : CS-63
Course Title : Introduction to Software
Assignment Number : BCA (3)-63/Assignment/2008
Maximum Marks : 25
Last Date of Submission :30th April, 2008/30th October, 2008


Question:-1 
Write algorithms and draw a corresponding flow chars to conver a decimal number to its
i- Binary equivalent.
ii- Octal equivalent.

Ans:- 
i) // Algorithm : Decimal to binary
start
1.let num be an array of integer
2.input no.
3.let rem=0,ctr=0
4.while(rem!=1)
begin
q=no/2
rem=no mod 2
num[ctr]=rem
ctr++
no=q
end
5.while(ctr>=0)
begin
print num[ctr]
ctr=ctr-1
end
end


//Shell program : Decimal to binary
clear
echo "Enter a No."
read n
b=" "
whil [$n-ne 0]
do b='expr $n %2'b
n='expr $n/2'
done
echo "Binary of $n=$b"

Flow chart unsolved.

ii) // Algorithm : Decimal to Octal
start
1.let num be an array of integer
2.input no.
3.let rem=0,ctr=0
4.while(rem!=1)
begin
q=no/8
rem=no mod 8
num[ctr]=rem
ctr++
no=q
end
5.while(ctr>=0)
begin
print num[ctr]
ctr=ctr-1
end
end

//Shell program : Decimal to Octal
clear
echo "Enter a No."
read n
o=" "
whil [$n-ne 0]
do o='expr $n %2'o
n='expr $n/8'
done
echo "Binary of $n=$o"

Flow chart unsolved.



Question :- 2
Consider the following set of processes that arrive in the ready queue at the same time:
                 Process                                 CPU time
                       P1                                         5
                       P2                                         6
                       P3                                         3
                       P4                                         7
                       P5                                         1
Consider the following scheduling algorithms:
First Come First Serve (FCFS), Shortest job first(SJF) and Round Robin (quantum=1)
-- What is the turnaround time of each process for each of the above scheduling algorithms? Also find the average turnaround time.
-- What is the waiting time of each process for each of the above scheduling algorithms? Also, find the average waiting time.

Ans:-

 
Process

CPU Time

P1 3
P2 6
P3 3
P4 7
P5 1

Using First Come First Serve (FCFS)



P1 P2 P3 P4 P5
0          3           9           12           19          20

 
Process Turnaround Time Waiting Time
P1 3 0
P2 9 3
P3 12 9
P4 19 12
P5 20 19
TOTAL 63 43

i) Turnaround Time = 63
    Average Turnaround Time = 63/5 = 12.6
ii) Wating Time = 43
    Average Time = 43/5 = 8.6

Using Shortest Job First (SJF) scheduling.

P5 P1 P3 P2 P4
0          1           4           7           13          20

Process P.T. Waiting Time
P1 4 1
P2 13 7
P3 7 4
P4 20 13
P5 1 0
TOTAL 45 25
I) Turn around Time = 45
    Average Turnaround time = 45/5 = 9
ii) Waiting Time = 25
    Average Waiting Time = 25/5 = 5

Using Round Robin scheduling with Quantum = 1

P1     P2     P3     P4     P5     P1     P 2     P3     P4     P1     P2     P3     P4     P2     P4     P2     P4     P2     P4     P4

Process Turnaround Time Waiting Time
P1 10 0+(5-1)+(9-6) = 7
P2 18 1+(6-2)+(10-7)+(13-11)+(15-12)+(17-16) = 14
P3 12 2+(7-3)+(11-8) = 9
P4 20 3+(8-4)+(12-9)+(14-13)+(16-15)+(18-17)+(19-19)+(20-20)=13
P5 5 4+0 = 4
TOTAL 65 47

i) Turnaround Time = 65
    Average Turnaround Time = 65/5 = 13
ii) Waiting time = 47
    Average Waiting Time = 47/5 = 9.4





Question:-3
Summarize the important features of LINUX operating system. Justify, how it is more advanced than earlier UNIX operating systems?

Ans:-
i) Linux is technically advanced:
It's technically superior to many other OS'es, like the infamous Redmond OS.
ii) Linux is highly configurable :
You can customize Linux exactly to your liking. You can make it work exactly the way you want, and on the plateform you want. You can also optimize your Linux system for your very own hardware, so you can run Linux faster and get every drops of performance squeezed out of your box.
iii)Linux is secure :
Linux has many advanced features that protect your system from both intrures (like vires etc.) and stupid users.
iv) Software dependencies:
Software dependencies is an excellent thing because it helps you keep things small and simple.

      Unix requires a more powerful hardware configuration. It will work in large mainframe computers but will not work in an x86 based personal computer. Linux however, has small hardware requirements and it will work on both a large mainframe computer and an x86 based personal computer.



Question:-4 
Write a shell programs for the following :
i-  Greatest common Divisor (GCD) of the given three numbers.
ii- To check whether the given number is an Avogadro number or not.

Ans:-
i) Unsolved
ii)
//To check whether the given number is an Avogadro number or not.
1. Set 0 to S,R
2. Input Num
3. Initialize T with Num
4. Repeat steps 5 to 7 until T>0
5. R=T mod 10
6. S=S+(R*R*R)
7. T=T/10
8. If S=Num then print "Avogadro Number" else
9. End



Question:-5
Derive  a regula grammer to describe the syntax of any two looping constructs of C programming language.

Ans:-
i) 
For loop of C language :
<stmt>::=for(exp1;exp2;exp3) <stmt>
start symbol::=<for>
<op> Terminal::=<for>
Non terminal::=<exp><stmt>
<exp>::=>stmt>op<stmt>
<op>::=<=|>|:=|=
<stmt>::=[a....b][A-Z][0-9]

ii)
While loop of C language:
<stmt>::=while<expr><stmt>end while
start symbol::=<while>
<expr>::=<ver>op<condition>
<op>::=<|>|!=|<>|
<ver>::=[a...b]|[A-Z]|[0-9]
<op>::=$$| || |!



Question:-6
List and execute the following UNIX commands
(a) To change the Password.
Ans- passwd
(b) To search the files in the current directiory/subdirectory for lines that matches a particular string pattern give.
Ans- grep "string" <file name>
(c) To print first 5 lines of a file.
Ans- head [-5] <filename>
(d) To print the number of processes run by a particular user.
Ans- ps -au
(e) To kill a process which is running in the background.
Ans- kill <process id number>
(f) To display the number of blank spaces in a given file.
Ans-
vi file name
:[on colon prompt] issue the following command
:set list on
Tabs will be displayed as ^I
Line feed will be displayed as $
(g) To sort alphabetically, a list of numbers stores in a data file in an ascending order.
Ans- sort -rn <file name>
(h) To convert the upper case letter to corresponding lower case letter's in a text file.
Ans- tr '[A-Z]' '[a-z]' <file name>
(i) To cound the number of users currently logged on.
Ans- who | wc-1
(j) To display the calender for a given month and year.
Ans- cal 'date "+%m +%y"'





Comments on this page:
Comment posted by chanel bags( oakwrslgmail.com ), 12/04/2012 at 9:18am (UTC):
Thanks a lot for sharing this with all of us you really understand what you are talking approximately! Bookmarked. Kindly also discuss with my web site =). We could have a hyperlink change arrangement among us!



Add comment to this page:
Your Name:
Your Email address:
Your website URL:
Your message:

Login
 
Username:
Password:
Advertisement
 
Donate
 
You can help this website
by donate or
you can click an
advertisement.

IGNOU Students
 
Sample Synopsis

Time Table BCA 2009
Projects (Vb n ASPnet) : Download
Synopsis Form

Training Letter

Guide Remuneration Form

Certificates of Originality

Java KeyWords - PDF

Java KeyWords - Wikipedia


Click Here / Click Here

Edit Plus (Use it as Java editor) Download

How to configure EditPlus to compile JAVA codes click here


Advertisement
 
PC Games (Full, Rip, Compressed)
 
 
© 2007 - 2009 HamidRaza - Today, there have been 9 visitors (104 hits) on this page!
=> Do you also want a homepage for free? Then click here! <=