Free Tutorials, Linux Command, Source Code Architecture,  Software Engineering, Intelligent Systems, RDBMS, Computer Accounting,  Operations Research, Discrete Mathematics, Network, SAD Lay Networks Lay Networks
Computer Science Networking Operating Systems Linux and Unix Source Code Script & Languages Protocols Glossary
 


Question 1. a : To Count number of character, words, & blank in a givent text

Clear

echo " Enter the String"

read str

echo $str > str.txt

len = 'echo $str | wc -c'

len = 'expr $len -1'

c= 0 , w = 0 , s = 0 , i = 1

echo " Length of string = $len"

w = 'echo $str | wc - w'

c = 'echo $str | wc -c'

while [ i -le $ len ]

do

st = 'cut - c$I str.txt'

if ["str" = " "] then

s = 'expr $s + 1'

fi

i = 'expr $i + 1

done

echo "Character = $c"

echo "Words = $w"

echo "Spaces = $s"

Question: 1.b : Write an algorithm/project to generate first prime numbers.

clear
no=1
r=0
while[$no -le 100]
do
t=0
i=1
while[$i -le $no]
do
rs='expr $no %$i'
if[$r -eq 0]
then
t='expr $i+1'
fi
i='expr $i+1'
done
if[$t -eq 2]
then
echo $no
fi
no='expr $no +1'
done

Algorithms

Step 1: START

Step 2: INPUT a positive number N to generate the

first N primenumbers.

Step 3: If N=1, then Print the number 2 and STOP.

Step 4: If N>1, then Print the first two prime numbers

2 and 3.

Step 5: Assign the value 2 to variable noprime and

value 4 tovariable num.

Step 6: If noprime=N, then goto Step-12.

Step 7: Assign value 2 to variable I.

Step 8: Divide the variable num by 2 and store in the

variable NUM1.

Step 9: Calculate the remainder of num divided by I

and store in variable number.

Step 10:If number=0, then increment num by 1 and goto

Step-7.

Step 11:If I=NUM1, then increment num by 1, noprime by

1,Print the value of num and goto Step-6.

Step 12:Increment the value of I by 1 and goto Step-8.

Step 13: STOP.

Question:1.C : Write a shell program to accept more than one month

#!/bin/sh
argstr=$@
argc=$#
year = `echo $argstr | awk '{print \$'$argc'`
cnt = 1
while { $cnt -lt $argc }
do
tmp = `echo $argstr | awk '{print \$'cnt '}'`
cal @tmp $year
cnt ='expr $cnt + 1'
done

Top

Back
Next
free computer articles
 

Copyright © 2000- 2008 Lay Networks All rights reserved. 

Web Hosting sponsored by Customized Software Company India
Web Site Designed by Web Designing, Flash Animation, Multimedia Presentations, Broacher/catalogue designing, Web Promotion 
Refer to your freind About Us Legal IGNOU Contact Us Feedback Donate to laynetworks.com Download Management Tutorials Tutorials History Search here