why is my code displaying values twice in a row?
// This code should display the square values of each odd integer within the range 1-13 inclusive. It should then add them togethger and output the final value which is 455. // For some reason, it is displaying the square numbers twice. This is causing the final value to be incorrect. //What have I tried? // oddInt *= oddInt in the for statement with oddInt++ in various places (after each var declaration or cw). // oddInt++ in the for statement. This way does output the correct suare numbers. However it displays them twice in a row so that the final value is 741. // namespace SoloLearn { class Program { static void Main(string[] args) { int sqrOddInt = 0; int oddIntTotal = 0; for (int oddInt = 1; oddInt <= 13; oddInt*= oddInt) { if (oddInt % 2 != 0) sqrOddInt = oddInt * oddInt; Console.WriteLine(sqrOddInt); oddIntTotal += sqrOddInt; } Console.WriteLine(); Console.WriteLine(oddIntTotal); } } }