Loading…
OS · Loops & numbers · Program 21 · In the record
write the shell script to print the power of an input number and bash without using any predefined function
1#!/bin/bash2 3echo "Enter the base:"4read base5 6echo "Enter the exponent:"7read exp8 9result=110 11for (( i = 1; i <= exp; i++ ))12do13 result=$((result * base))14done15 16echo "$base ^ $exp = $result"2 ⏎ 10Enter the base: 2 Enter the exponent: 10 2 ^ 10 = 1024
Run program 21 in your browser
bash · just-bash. Change the code or the input, run it, break it, and see what happens.