Tricker
Tricker

Reputation: 11

Different IDEs are giving different output, why?

When code is executed in VS Code and OnlineGDB, the outputs are different.

Code:

#include <iostream>
#include <cmath>
using namespace std;

int main() {
    int sum = 0;
    int i = 2;

    while(i != 0){ 
        sum = sum + pow(10, i); 
        i--;
    }

    cout << sum;
    return 0;
}

VS Code
image

OnlineGDB
image

The output in VS Code gives 109, but the same code in OnlineGDB gives 110, which is expected.

Why is this happening?

Upvotes: 0

Views: 98

Answers (0)

Related Questions