Programming Problems
Home
PROGRAMS
DOWNLOAD
ABOUT
CONTACT
Saturday, 16 July 2016
Write a shell script in Linux/Unix to find the sum of squares of n natural numbers.
tput clear
echo ENTER THE NUMBER OF ELEMENTS-
read n
i=1
sum=0
while test $i -le $n
do
p=`expr $i \* $i`
sum=`expr $sum + $p`
i=`expr $i + 1`
done
echo $sum
OUTPUT:
ENTER THE NUMBER OF ELEMENTS-
5
55
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
Popular Posts
Write a shell script in Linux/Unix to generate Fibonacci series.
tput clear echo enter the range of the fibonacci series---- read n echo ------------------------------------------------- a=0 b...
Write a program in assembly language(8085) to check a number for odd or even parity.
LXI H, 2000H MOV A, M INX H ORA A JPE EVEN MVI M, 00H HLT EV...
No comments:
Post a Comment