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
Math,
15 days ago
Science,
15 days ago
English,
30 days ago
Social Sciences,
30 days ago
India Languages,
8 months ago
Math,
8 months ago