Computer Science, asked by Pratham9227, 1 month ago

The program to print the sum of all cubes that lie between 0 and 100 is given below.Does this program have an error? If yes, which statement should be modified tocorrect the program?integer i = 0, a // Statement 1integer sum = = 0;a = (i*i*i)while (i<100) // Statement 2{sum = sum + a // Statement 3i = i + 1a = (i*i*i) // Statement 4}print sum​

Answers

Answered by kothapallisagarvivek
5

Answer:

statement 2

Explanation:

It should be while(a<100)

because a is the cubic number and according to the question it should be in the range of 0-100 only

Answered by jubin22sl
0

Answer: The correct syntax to calculate cube of numbers between 0 to 100 is given below

The programming language used is Python and C++

Explanation:

#PYTHON

sum = 0

for i in range (100):

 sum = sum + (i**3)

print(sum)

#C++

#include<iostream>

using namespace std;

int main(){
int a = 0;

for(int i=0; i <=100; i++){
a + = i*i*i;

cout << a << endl;

}

return 0;

}

#SPJ2

Similar questions