-8
#include <iostream>
using namespace std;
int main() {
    int a=0,b=0;
    cin>>a>>b>>endl;
    for(int i=a;i<=b;++i)
    cout<<i<<endl;
    return 0;
}

I want to see the output is about the integers inclusive between a and b, but after entering two numbers, it shows no output..

Shades
  • 5,568
  • 7
  • 30
  • 48

3 Answers3

0
#include <iostream>
using namespace std;
int main() {
    int a = 0, b = 0;
    cin >> a;
    cin >> b;
    for (int i = a; i <= b; i++)
        cout << i << endl;
    return 0;
}

EDIT: I removed something as it wasn't true :P Silly me.

Also 'endl' doesn't work with cin :)

HowITsDone
  • 60
  • 8
0
    #include <iostream>
using namespace std;
int main() {
    int a=0,b=0;
    cin>>a>>b>>endl;
    for(int i=a;i<=b;++i)
    cout<<i<<endl;
    return 0;
}

First you can't use endl in cin Second you wrote ++i inside your for loop which will increase value of by i means value of will become 1 from 0. Therefore the condition will never be true as value of b is 0.

THE CORRECT WAY

    #include <iostream>
using namespace std;
int main() {
    int a=0,b=0;
    cin>>a>>b;
    for(int i=a;i<=b;i++)
    cout<<i<<endl;
    return 0;
}
Ganofins
  • 41
  • 2
  • 12
-1

The code is wrong because you have already got a and b equal to 0,and after that you are taking a and b as inputs. If you wanna take them as inputs you should write int a,b. NOT int a=0,b=0

yoron
  • 1
  • 4