Write a C++ program to print all numbers between a and b (a and b inclusive) using for loops.
1 2 3 4 5 6 7 8 9 10 11 12 |
#include <iostream> using namespace std; int main() { int a=2; int b=100; for(int loop=a; loop<=b; loop++) { cout << "All numbers between a and b are:"<<loop<<endl; } return 0; } |
Output
It will print all numbers from 2 to 100.