fork download
  1. ]#include <iostream>
  2. using namespace std;
  3. long int funcn(long int);
  4. int main()
  5. {
  6. int t;
  7. scnaf("%d", &t);
  8. while (t > 0)
  9. {
  10. long int n;
  11. scanf("%ld", &n);
  12. long int ans = funcn(n);
  13. while (ans % 10 > 0)
  14. ans = funcn(ans);
  15. printf("%ld \n", ans);
  16. t --;
  17. }
  18. return 0;
  19. }
  20. long int funcn(long int n)
  21. {
  22. long int sum = 0;
  23. int digit;
  24. while (n > 0)
  25. {
  26. digit = n % 10;
  27. sum += digit;
  28. n /= 10;
  29. }
  30. return sum;
  31. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:2: error: stray '#' in program
 ]#include <iostream>
  ^
prog.cpp:1:1: error: expected unqualified-id before ']' token
 ]#include <iostream>
 ^
prog.cpp: In function 'int main()':
prog.cpp:7:16: error: 'scnaf' was not declared in this scope
  scnaf("%d", &t);
                ^
prog.cpp:11:18: error: 'scanf' was not declared in this scope
   scanf("%ld", &n);
                  ^
prog.cpp:15:23: error: 'printf' was not declared in this scope
   printf("%ld \n", ans);
                       ^
stdout
Standard output is empty