Answer to Question #258708 in C++ for kate

Question #258708

Input

The program will accept a single text input.

Output

After the user encodes his/her text input, the program examines the text's structure which includes:

  1. The number of letters (regardless if its uppercase/lowercase)
  2. The number of numeric characters
  3. The number of special characters
  4. The number of vowels together with the actual vowels from the input
  5. The number of consonants together with the actual consonants from the input
  6. The count of the numeric characters together with the actual numeric characters from the input
  7. The count of the special characters together with the actual special characters from the input

sample Input

october/15/1975

Sample Output

7:letters

6:numbers

2:special-characters

3:ooe

4:ctbr

6:151975

2://



1
Expert's answer
2021-10-29T15:19:41-0400
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include<ctype.h>




#define SIZE 200 


int main()
{
    char string[SIZE];
    int alphabet, numbers, special_characters, x;
    alphabet = numbers = special_characters = x = 0;




       printf("\n\nEnter the string :\n");
     
       fgets(string, sizeof string, stdin);	


    


    while(string[x]!='\0')
    {
        if((string[x]>='a' && string[x]<='z') || (string[x]>='A' && string[x]<='Z'))
        {
            alphabet++;
        }
        else if(string[x]>='0' && string[x]<='9')
        {
            numbers++;
        }
        else
        {
            special_characters++;
        }
        
        


        x++;
    }




      
    printf("\n%d: letters\n", alphabet);
    printf("%d: numbers\n", numbers);
    printf("%d: special-characters\n\n", special_characters-1);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS