Logo 
Search:

Unix / Linux / Ubuntu Articles

Submit Article
Home » Articles » Unix / Linux / Ubuntu » Homework HelpRSS Feeds

Script to find the value of one number raised to the power of another

Posted By: Ludwik Fischer     Category: Unix / Linux / Ubuntu     Views: 9396

Write a script to find the value of one number raised to the power of another. Two numbers are entered through the keyboard.

Code for Script to find the value of one number raised to the power of another in Unix / Linux / Ubuntu

echo "Input number"
read no
echo "Input power"
read power

counter=0
ans=1
while [ $power -ne $counter ]
do
        ans=`expr $ans \* $no`
        counter=`expr $counter + 1`
done

echo "$no power of $power is $ans"
 

Input number
3
Input power
2
3 power of 2 is 9
  
Share: 



Ludwik Fischer
Ludwik Fischer author of Script to find the value of one number raised to the power of another is from Frankfurt, Germany.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!