How to find the sum of squares of odd numbers using python or c or any computer language.
Answers
Answered by
0
Answer:
Hello,
Here is how I did this:
// declare vaiables
int minNumber = 1, maxNumber = 30; //loop bounds
int loopCounter; // to use in the for loop
int totalSum = 0; // to get the sum from 1 to 30
// for loop to calculate the sum
for (loopCounter = minNumber; loopCounter <= maxNumber; loopCounter++)
{
// to only get the odd numbers
if (loopCounter % 2 != 0)
{
// to calculate
totalSum = totalSum + loopCounter;
}// end if
}// end for
Hope this helps!!
Similar questions
Chemistry,
1 month ago
English,
2 months ago
Social Sciences,
2 months ago
India Languages,
9 months ago
Math,
9 months ago