Xylem Number is a number whose sum of extreme (last and first) digits is equal to sum of it’s mean (all other digits except last and first) digits.
Phloem Number is a number which does not hold the above condition.
Example 1: 21201. 2+1 = 1+2+0. We observer sum of extremes and means are equal. Hence it is a Xylem Number.
Example 2: 21211. 2+1 != 1+2+1. Here sum of extremes and means are not equal. Hence it is a Phloem Number.
C
#include <stdio.h>
void main()
{
int n=0,r=0,nCopy=0,eSum=0,mSum=0;
printf("Enter a number: ");
scanf("%d",&n);
nCopy=n;
while(n>0)
{
r=n%10;
if(n==nCopy||n<10)
{
eSum=eSum+r;
}
else
{
mSum=mSum+r;
}
n=n/10;
}
if(eSum==mSum)
{
printf("%d is a Xylem Number",nCopy);
}
else
{
printf("%d is a Phloem Number",nCopy);
}
}C