Computer Science, asked by rajpriya3186, 11 months ago

Write a program to print sum of cubes of odd numbers between 1 and 10........​

Answers

Answered by aadarshr13299
2

Answer:

HOPE it helps you..

Explanation:

// Simple C++ method to find sum of cubes of

// first n odd numbers.

#include <iostream>

using namespace std;

int cubeSum(int n)

{

int sum = 0;

for (int i = 0; i < n; i++)

sum += (2*i + 1)*(2*i + 1)*(2*i + 1);

return sum;

}

int main()

{

cout << cubeSum(2);

return 0;

}

Answered by AskewTronics
0

Program in python :

Explanation:

sum_value=0

for x in range(1,11):#for loop which runs from 1 to 10.

   if(x%2!=0):#chech the if condition.

       sum_value=sum_value+(x*x*x)#add the cube value.

print(sum_value)#print the sum.

Output:

  • The above code will print the "1225", which is the sum value of cube of 1 to 10.

Code explanation :

  • The above code is in python language, which have one for loop which runs for the value of 1 to 10. Then the if condition will check for the odd number.
  • Then the cube of odd number will be added on the sum_value variable.
  • Then the sum will be printed by the help of print function.

Learn More:

  • Python : https://brainly.in/question/15747805
Similar questions