A number is taken from user and the sum of the digits is displayed.
Select To use this code as it is.. select and copy paste this code into code.cpp file :)
- #include<iostream.h>
- #include<conio.h>
- void main()
- {
- clrscr();
- int n,sum=0,m;
- cout<<"please enter a five digit no.: ";
- cin>>n;
- while(n>0)
- //Coding by: Snehil Khanor
- //http://WapCPP.blogspot.com
- {
- m=n%10;
- sum=sum+m;
- n=n/10;
- }
- cout<<sum;
- getch();
- }
0 comments:
Post a Comment