Advertisement
TeslaCoilGirl

a=1 b=2

Aug 29th, 2019
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.74 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. int main() {
  5.  
  6.     char myWord[250];
  7.     printf("If A = 1, B = 2, C = 3, etc. then words have a numerical value.\n");
  8.  
  9.     while (myWord != '100') {
  10.  
  11.  
  12.         printf("Enter word you want to calculate the value of. (Max 250 chars)\n");
  13.         scanf("%s", myWord);
  14.  
  15.         for(int i = 0; i <= strlen(myWord); i++){
  16.             myWord[i] = toupper(myWord[i]);
  17.         }
  18.  
  19.         int wordCounter = 0;
  20.  
  21.  
  22.         for(int i = 0; i <= strlen(myWord); i++){
  23.             int charCounter = 0;
  24.  
  25.             for(char j = 'A'; j <= myWord[i]; j++){
  26.                 charCounter++;
  27.             }
  28.  
  29.         wordCounter += charCounter;
  30.         }
  31.  
  32.         printf("%d\n\n", wordCounter);
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement