Wednesday, July 5, 2017

while loop in C++

C++ program to print 1 to 10 numbers using while loop.

#include<iostream>
using namespace std;
int main()
{
  int i=1;
  while(i<=10)
  {
    cout << i << " ";
    i++;
  }
  return 0;
}

Output of the program

1 2 3 4 5 6 7 8 9 10

No comments:

Post a Comment