Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Cpp program to count the letters on a paragraph and describe it precisely.
- // created on July, 2016
- // Author: fueanta
- #include <iostream>
- using namespace std;
- int main(){
- int small[26]={0},capital[26]={0};
- cout << "Give your sentence please: ";
- string sent;
- getline(cin,sent); //passing &sent[0]
- for (int i=0;sent[i]!='\0';i++){
- if (sent[i]>='A' && sent[i]<='Z'){
- capital[int(sent[i])-65]++;
- }
- else if (sent[i]>='a' && sent[i]<='z'){
- small[int(sent[i])-97]++;
- }
- }
- cout << "\n\nThe sentence has ";
- for (int i=0;i<25;i++){
- if (capital[i]>0){
- cout << char(i+65) << " in " << capital[i] << " place(s), ";
- }
- }
- for (int i=0;i<25;i++){
- if (small[i]>0){
- cout << char(i+97) << " in " << small[i] << " place(s), ";
- }
- }
- cout << "\n\n";
- return 0;
- }
Add Comment
Please, Sign In to add comment