- Home
- Course Category
- Course Result
- Course Detail
Hot Line: 0124-2383121
Course Introduction
Programs for practice
Following C++ program ask from the user to enter any number to add the digits of that number along with the number itself: in C++
Source Code: Add Digits of Number
/* C++ Program - Add Digits of Number */ #include<iostream.h> #include<conio.h> void main() { clrscr(); int num, rem=0, sum=0; cout<<"Enter a Number :"; cin>>num; int temp=num; while(num>0) { rem=num%10; sum=sum+rem; num=num/10; } cout<<"Sum of the digits of "<<temp<<" is "<<sum; getch(); }Output
Enter a Number : 124 Sum of digits of 124 is 7