1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
// This program prompts the user to enter a sentence and translates the characters
// into their corresponding integers in an array. Then prints the sum of the
// integers in each word.
#include <iostream>
#include <string>
#include <stdio.h>
#include <ctype.h>
using namespace std;
int main()
{
char Alpha[26] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
char str[]= "The big Cat.\n";
char sentence;
int count, value;
// letters to numbers
for (count = 0; count < 26; count++)
{
value = count;
}
// convert sentence to lower case
cout << "Enter your sentence: ";
cin >> sentence;
while (str[count])
{
sentence = str[count];
putchar(tolower(sentence));
count++;
}
return 0;
}
|