sahajjain01

Add first 10 natural numbers using while loop.

Aug 4th, 2013
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.22 KB | None | 0 0
  1. //Program to add first 10 natural numbers using while loop.
  2. #include<iostream.h>
  3. #include<conio.h>
  4. void main()
  5. {
  6.     clrscr();
  7.     int a=0,b=0;
  8.     while(a<10)
  9.     {
  10.         ++a;
  11.         b=a+b;
  12.     }
  13.     cout<<"The sum is: "<<b;
  14.     getch();
  15. }
Advertisement
Add Comment
Please, Sign In to add comment