#include<conio.h>
#include<iostream.h>
void main()
{
clrscr();
long int a,b,c,d,e,f,g,h,i,j;
cout<<"Enter the no. ( max 5 digits) ";
cin>>a;
b=a/10000;
c=a/1000;
d=c%10;
e=a/100;
f=e%10;
g=a/10;
h=g%10;
i=a%10;
j=b+d+f+h+i;
cout<<"Sum of the digits = "<<j;
getch();
}
#include<iostream.h>
void main()
{
clrscr();
long int a,b,c,d,e,f,g,h,i,j;
cout<<"Enter the no. ( max 5 digits) ";
cin>>a;
b=a/10000;
c=a/1000;
d=c%10;
e=a/100;
f=e%10;
g=a/10;
h=g%10;
i=a%10;
j=b+d+f+h+i;
cout<<"Sum of the digits = "<<j;
getch();
}
No comments:
Post a Comment