Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Program to add first 10 natural numbers using while loop.
- #include<iostream.h>
- #include<conio.h>
- void main()
- {
- clrscr();
- int a=0,b=0;
- while(a<10)
- {
- ++a;
- b=a+b;
- }
- cout<<"The sum is: "<<b;
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment