(2009 – 2010)

                  

                

                        

                                        



-:PROGRAM TO ADD AND MULTIPLY TWO NUMBERS:-

SOURCE CODE

echo Enter the value of A:

read A

echo Enter the value of B:

read B

C = ’expr $A+ $B’

echo The sum of A and B is $C

 C = ’expr $A\* $B’

echo The product of A and B is $C

OUTPUT

Enter the value of A: 25

Enter the value of B: 20

The sum of A and B is 45

The product of A and B is 500


-:PROGRAM TO CALCULATE THE FACTORIAL OF A NUMBER:-

SOURCE CODE

echo Enter a number:

read n

i=1

f=1

while [$i –le $n]

do

f = ’expr $f \* $i ‘

i = ‘ expr $i + 1 ’

done

echo Factorial of $n is $f

OUTPUT

Enter a number: 5

Factorial of 5 is 120


-:PROGRAM TO CHECK A NUMBER WHEATHER IT IS A PRIME NUMBER OR NOT:-

Join now!

SOURCE CODE

echo Enter an integer number:

read num

o= ‘ expr $num/2 ‘

flag = 0

i=2

while [ $i –le $o]

do

m = ’expr $num % $i ‘

if[$m –eq 0]

then

flag = 1

fi

i = ‘ expr $i + I ’

done

if [ $flag –eq 0]

then

echo The number is a prime number.

else

echo The number is not a prime number.

fi          

OUTPUT

Enter an integer number: 11

The number is a prime number.

Enter an integer number: 27

The number is ...

This is a preview of the whole essay