Advertisement
Guest User

Untitled

a guest
Jun 24th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. char letter;
  6. int l, word, num, i, s;
  7. int factorial = 1;
  8.  
  9. printf("Input a word in all lowercase to be checked, with no spaces: ");
  10. //scanf("%s", &word);
  11.  
  12. do
  13. {
  14. letter = getchar();
  15. (int) letter;
  16. l = letter - 96;
  17. word = word + l;
  18. } while (letter != '\n');
  19.  
  20. printf("%d", word);
  21.  
  22. do
  23. {
  24. num = word % 10;
  25. for (i=num; i>0; i--)
  26. {
  27. factorial = factorial*i;
  28. }
  29. word = word/10;
  30. s = s + factorial;
  31. } while (word != 0);
  32.  
  33. printf("\n%d", s);
  34.  
  35. /*if(s == word)
  36. {
  37. printf("The word you have entered is a Krishnamurti number.");
  38. }
  39.  
  40. else
  41. {
  42. printf("The word you have entered is not a Krishnamurti number.");
  43. }*/
  44.  
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement