LINUX SEHLL PROGRAM FOR FINDING MULTIPLICATION AND SQUARE OF 1-10 NUMBERS | OPERATING SYSTEM (OS) LAB IN LINUX

AIM:
To write a shell program for the following:
(i) multiplication table
(ii) square of 1-10 numbers.
ALGORITHM:
Multiplication table:
· Get the numbers to be displayed for multiplication and limit of the multiplication table.
· Check using while loop.
· Calculate the result.
· Increment the variable and repeat.
· Display the value an terminate the program.
interchanging two numbers using without temporary variable:
· Using for loop read number from 1-10.
· Calculate the square of 1’s number and assign it to value.
· Repeat the step for all number one by one.
· Display the result.
· Terminate the program.

PROGRAM SOURCE CODE
(i) multiplication table:
echo ”enter a”
read n
echo “multiple”
for I in 1 2 3 4 5 6 7 8 9 10
do
m= `expr $n\*$i `
echo “$i x $n = $m”
done

(ii) square of 1-10 numbers:
for I in 1 2 3 4 5 6 7 8 9 10
do
t= `expr $i\* $i `
echo “square of $i is $t”
done

CONCLUSION:
Thus the shell program for displaying the multiplication table of any number and the square of 1-10 numbers are written and executed successfully.

Related post