ALl i need to find is the sum of digits of a given number until the sum becomes a single digit. (e.g. 12345=>1+2+3+4+5=15=>1+5=6).I have coded with some logic and i could able to find the sum til this part 12345=>1+2+3+4+5=15 but i couldn able to carry on after that plz guide me with that
#include <stdio.h>
#include <stdlib.h>
/* Puzzle A20 - print a triangle of stars, n rows tall */
int main(int argc, char *argv[])
{
int sum = 0;
int n;
scanf("%d",&n);
int t = n;
while (n > 0) {
int p = n % 10;
sum = sum + p;
n = n / 10;
}
printf("%d", sum);
}