1) Write a script using for statement(s) to printout the following? ****** *****
ID: 3850538 • Letter: 1
Question
1) Write a script using for statement(s) to printout the following?
******
*****
****
***
**
*
**
***
****
*****
******
2) Write Script called maxmin to find out the biggest and the smallest numbers from given five numbers. Numbers are supplies as command line arguments. Print error message if sufficient arguments are not supplied.
This script works as follows $ maxmin 17 12 44 5 19
Max = 55
Min = 5
$ maxmin 300 29 277 888 99
Max = 888
Min = 29
3) Write a script called srm (super remove) that deletes the specified filename(s) and asks for confirmation before deletion.
Q.4. Write Script calculate, using case statement to perform basic math operation as
follows
+ addition
- subtraction
x multiplication
/ division
This script works as follows
$ calculate 20 / 4,
Result = 5
$ calculate 12 - 2,
Result = 10
$ calculate 7 x 5,
Result = 35
$ calculate 18 + 12,
Result = 30
Also this script should check for sufficient command line arguments
Explanation / Answer
2.arrayName(1 2 3 4 5)
max=${arrayName[0]}
Min=${arrayName[0]}
for i in "${arrayName[@]}"
Do
if [[" $i" - gt "$max" ]] ;then
max ="$i"
fi
If[[ "$i" - lt '$min"]] ;then
Min="$i"
fi
done
Or if we want to prompt the input gor user then the following code can be usefull
n=5
array()
While ((n)) ;do
read - p' [$n] enter the numbers:" i
[[ $i =~^[+-]?[[:digit:]] +$]] || continue
Array+=($i)
((--n))
done
{read min;max=$(tail - nl) ;} <<(printf "%s/n" "${array[@]}" | sort - n)
echo "min=$min"
echo "max=$max"
4.<html>
<head>
<title>badic airthemetic operations </title>
<script language ="Javascript " type=text/Javascript '>
Function multiply() {
a=Number(document. Calculator. Number1. Value) ;
b=Number(document. Calculator. Number2. Value) ;
C=a*b;
document. Calculator. total. Value =c;}
</script>
// in the same for all other operations also same script but just need to change the line c=a+b for addition c=a-b for subtraction c=a/b for division remaining all same
After that in body
<body>
<input type="button " value=" MUL" ;">
Same above is common for all operations just u need to add the operation name in the value filed and onclick filed
</form>
</body>
</html>
3 function delete(file_name)
{var r =confirm("are u sure u want to delete this file? ")
if(r==true)
{
var file_path =<? php echo dirname(_FILE_). '/uploads/'? >+file_name;
file_path. Remove() ;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.