You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//34. Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example, if we conisder 98, we get 9+8 = 17 after first addition. Then we get 1+7 = 8. We stop at this point because we are left with one digit.
#include <stdio.h>
int main() {
// Input non-negative integer
int num;
printf("Enter a non-negative integer: ");
scanf("%d", &num);
// Repeatedly add all the digits until the result has only one digit