9. Write a Shell program to find the sum of all numbers between 50 and 100, which are divisible by 3 and not divisible by 5.
Answers
Answered by
2
Explanation:
hiii k bhatia hope u are fine
Answered by
0
Answer:
#!/bin/bash
# Set initial sum to 0
sum=0
# Loop through numbers between 50 and 100
for ((i=50; i<=100; i++))
do
# Check if the number is divisible by 3 and not divisible by 5
if ((i % 3 == 0)) && ((i % 5 != 0))
then
# If so, add the number to the sum
sum=$((sum + i))
fi
done
# Print the sum
echo "The sum of all numbers between 50 and 100, which are divisible by 3 and not divisible by 5 is: $sum"
Explanation:
refer comments
Similar questions