z.k
z.k

Reputation: 45

different results because of new line character

I wrote below program that prints even numbers from 100 to 1000 but when i change cout<<i<<" "; with cout<<i<<"\n"; it starts from 410 not 100.

Why they have different results?

#include <iostream>
using namespace std;
int main()
{
    int k;
    for(int i=100;i<=1000;i++)
    {
        k=i%2;
        if(k==0)
        cout<<i<<" ";
    }

    return 0;
}

Upvotes: 0

Views: 91

Answers (1)

Renuka Deshmukh
Renuka Deshmukh

Reputation: 998

You are still getting correct output. But due to the limited size of your output console, you are unable to see the top 200 or so entries.

Upvotes: 4

Related Questions