C++ Program to find Sum of Given Digits

C++ Program to find Sum of Given Digits



#include
#include
void main()
{
int d1,ori,add;
add=0;
cout<<"enter the number";
cin>>ori;
while(ori!=0)
{
d1=ori%10;
ori=ori/10;
add=add+d1;
}
cout<<"sum of digit"<<add;
getch();
}



No comments:

Post a Comment