Sunday, December 14, 2008

FIND THE SUM OF DIGIT THREE Numbers

/* FIND THE SUM OF DIGIT THREE NO'S*/
#include "math.h"
main()
{
int d,d1,d2,d3,r1,r2,sum;
clrscr();
printf("\n enter any three digit no's");
scanf("%d",&d);
d1=d/100;
r1=d%100;
if(r1!=0)
{
d2=r1/10;
r2=r1%10;
if(r2!=0)
d3=r2;
else
d3=0;
}
else
d2=0;
d3=0;
}
sum=d1+d2+d3;
printf("\n sum of 3 digit no is %d",sum);
getch();
}

No comments:

Post a Comment