FC Assignment: Question 1:write A Shell Script To Find The Sum of Numbers From 1 To 10
FC Assignment: Question 1:write A Shell Script To Find The Sum of Numbers From 1 To 10
Question 1:Write a shell script to find the sum of numbers from 1 to 10.
Code
# !/ bin / bash
sum =0
for (( i =1; i <=10; i ++) )
do
sum = $ (( sum + i ) )
done
echo " Sum of numbers from 1 to 10 is : $sum "
Program 1: Shell program to find sum of numbers from 1 to 10
Output
Code
# !/ bin / bash
Output
1
Exercise 3:Create a calculator using html css and javascript
Code calculator.html
<! DOCTYPE html >
< html lang = " en " >
< head >
< meta charset = " UTF -8 " / >
< title > Calculator HTML CSS JavaScript | CodingNepal </ title >
< link rel = " stylesheet " href = " style . css " / >
< link rel = " stylesheet " href = " ../ custom - styles . css " / >
< script src = " ../ custom - scripts . js " defer > </ script >
< style >
. download - btn - cn a {
background : none ;
color : #2 f9fff ;
border : 2 px solid #2 f9fff ;
}
. download - btn - cn a : hover {
color : # fff ;
background : #2 f9fff ;
}
</ style >
</ head >
< body >
< div class = " container " >
< input type = " text " class = " display " disabled / >
< div class = " buttons " >
< button class = " operator " data - value = " AC " > AC </ button >
< button class = " operator " data - value = " DEL " > DEL </ button >
< button class = " operator " data - value = " % " >% </ button >
< button class = " operator " data - value = " / " >/ </ button >
< button data - value = " 7 " >7 </ button >
< button data - value = " 8 " >8 </ button >
< button data - value = " 9 " >9 </ button >
< button class = " operator " data - value = " * " >* </ button >
< button data - value = " 4 " >4 </ button >
< button data - value = " 5 " >5 </ button >
< button data - value = " 6 " >6 </ button >
< button class = " operator " data - value = " -" > - </ button >
< button data - value = " 1 " >1 </ button >
< button data - value = " 2 " >2 </ button >
< button data - value = " 3 " >3 </ button >
< button class = " operator " data - value = " + " >+ </ button >
< button data - value = " 0 " >0 </ button >
< button data - value = " 00 " > 00 </ button >
< button data - value = " . " >. </ button >
< button class = " operator " data - value = " = " >= </ button >
</ div >
</ div >
< script src = " script . js " > </ script >
</ body >
</ html >
Program 3: HTML code for Calculator
2
style.css
* {
margin : 0;
padding : 0;
box - sizing : border - box ;
font - family : " Poppins " , sans - serif ;
}
body {
height : 100 vh ;
display : flex ;
align - items : center ;
justify - content : center ;
background : # e0e3eb ;
}
. container {
position : relative ;
max - width : 340 px ;
width : 100%;
border - radius : 12 px ;
padding : 10 px 20 px 20 px ;
background : # fff ;
box - shadow : 0 5 px 10 px rgba (0 , 0 , 0 , 0.05) ;
}
. display {
height : 80 px ;
width : 100%;
outline : none ;
border : none ;
text - align : right ;
margin - bottom : 10 px ;
font - size : 28 px ;
color : #000 e1a ;
background : # fff ;
pointer - events : none ;
}
. buttons {
display : grid ;
grid - gap : 10 px ;
grid - template - columns : repeat (4 , 1 fr ) ;
}
. buttons button {
padding : 10 px ;
border - radius : 6 px ;
border : none ;
font - size : 23 px ;
cursor : pointer ;
background - color : # eee ;
}
. buttons button : active {
transform : scale (0.99) ;
}
. operator {
color : #2 f9fff ;
}
Program 4: CSS stylesheet for Calculator
script.js
const display = document . querySelector ( " . display " ) ;
const buttons = document . querySelectorAll ( " button " ) ;
3
const specialChars = [ " % " , " * " , " / " , " -" , " + " , " = " ];
let output = " " ;
Output