1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
xeze [42]
3 years ago
5

Write a function chat accepts a pointer to a C-string as its argument. The function should count the number of vowels appearing

in the sering and rerurn that number. Write another function that accepts a pointer to a C-string as its argument. This function should count the number of consonants appearing in the string and return that number. Demonstrate these two functions in a program rhar performs the following steps: I. The user is asked to enter a string. 2. The program displays the following menu: A) Count the number of vowels in rhe string 8) Count the number of consonants in the string C) Count both the vowels and consonants in the string D) Enter another string E) Exit the program 3. The program performs the operation selected by the user and repeats until the user selects E to exit the program.
Computers and Technology
1 answer:
Dovator [93]3 years ago
8 0

Answer:

Function contains into the code asked for:

  • Receives a string as an argument.  
  • count the number of vowels in the string and return that number.
  • receives a string as an argument.
  • count the number of consonants in the string and return that number.  

Explanation:

//Let's call libraries

#include <stdio.h>  

#include <conio.h>

//Start main

int main()

{

//*Declare functions for counting number of vowels and consonants

int vowels=0;      

int consonants=0;    

int all=0;    

//Output need information

//Ask user to input a string

printf("what do you want to count?\n");    

printf("1-the vowels.\n");      

printf("2-the consonants.\n");    

printf("3-all of the letters on a phrase.\n");      

printf("\n");      

printf("-> ");      

int a;    

a = getchar();

   switch (a)

   {          

//Ask user what function they want to run

case '1':

//Call the function needed to count the vowels  

            printf("Introduce a phrase: ");                  

char textoa[1001];                

scanf("%s", &textoa);

char *p;                  

p = textoa;                

while (*p != '\0')

               {

                     if (*p == 'a' || *p == 'e' || *p == 'i' || *p == 'o' || *p == 'u' || *p == 'A' || *p == 'E' || *p == 'I' || *p == 'O' || *p == 'U') vocales ++;

                     p++;

               }

               printf("there are %d vowels.", vowels);                  

break;            

case '2':

//Call the function needed to count the consonants

printf("Introduce a phrase: ");                

char textob[1001];                

scanf("%s", &textob);

p = textob;                

while (*p != '\0')

               {

                     if (*p == 'b' || *p == 'B' || *p == 'c' || *p == 'C' || *p == 'd' || *p == 'D' || *p == 'f' || *p == 'F' || *p == 'g' || *p == 'G' || *p == 'h' || *p == 'H' || *p == 'j' || *p == 'J' || *p == 'k' || *p == 'K' || *p == 'l' || *p == 'L' || *p == 'm' || *p == 'M' || *p == 'n' || *p == 'N' || *p == 'p' || *p == 'P' || *p == 'q' || *p == 'Q' || *p == 'r' || *p == 'R' || *p == 's' || *p == 'S' || *p == 't' || *p == 'T' || *p == 'v' || *p == 'V' || *p == 'w' || *p == 'W' || *p == 'x' || *p == 'X' || *p == 'y' || *p == 'Y' || *p == 'z' ||  

*p == 'Z') consonants ++;

                     p++;

               }

               printf("there are %d consonants.", consonants);                  

break;            

case '3':

printf("Introduce a phrase: ");                

char textoc[1001];                

scanf("%s",&textoc);

p = textoc;                

while (*p != '\0')

               {

                     if (*p == 'a' || *p == 'e' || *p == 'i' || *p == 'o' || *p == 'u' || *p == 'A' || *p == 'E' || *p == 'I' || *p == 'O' || *p == 'U' || *p == 'b' || *p == 'B' || *p == 'c' || *p == 'C' || *p == 'd' || *p == 'D' || *p == 'f' || *p == 'F' || *p == 'g' || *p == 'G' || *p == 'h' || *p == 'H' || *p == 'j' || *p == 'J' || *p == 'k' || *p == 'K' || *p == 'l' || *p == 'L' || *p == 'm' || *p == 'M' || *p == 'n' || *p == 'N' || *p == 'p' || *p == 'P' || *p == 'q' || *p == 'Q' || *p == 'r' || *p == 'R' || *p == 's' || *p == 'S' || *p == 't' || *p == 'T' || *p == 'v' || *p == 'V' || *p == 'w' || *p == 'W' || *p == 'x' || *p == 'X' || *p == 'y' || *p == 'Y' || *p == 'z' || *p == 'Z') all ++;

                     p++;

               }

               printf("there are %d letters on the phrase.", all);                 break;

   }     getch();

}

You might be interested in
How did hitles rules in nazi germany exemplify totiltarian rule?
ddd [48]

Answer:

hope this helps if not srry

7 0
2 years ago
Two strategies for keeping your files in sync
zlopas [31]

Answer:

1. MS Cloud

2. G Drive

Explanation:

5 0
3 years ago
When you tell an acquaintance your telephone number, you do not recite the digits one by one at a constant rate, as in "3, 3, 7,
yKpoI14uk [10]

Answer:

chunking and short-term is the correct answer of this question.

Explanation:

chunking is a strategy to enhance a short-term memory.

Chunking is an method used to separate larger numbers that can not be psychologically separated.Chunking is the grouping of words in one sentence into short, important phrases. A chunk is the material segment that is used in many graphical formats, such as PNG etc.

Short-term memory is the knowledge a person is considering or is conscious of. This is also called healthy or main memory.

3 0
3 years ago
What is the platform-neutral programming language that can run on Windows, Macintosh, or UNIX?
nadezda [96]

Answer:

java

Explanation:

4 0
2 years ago
_________ local variables retain their value between function calls.
SOVA2 [1]

Answer: static

Explanation:

variables when declared static gets called statically meaning whenever a function call is made it get stored and it is not required to get the variable again when the function is again called. There scope is beyond the function block

4 0
3 years ago
Other questions:
  • The optional feature in a business letter is
    10·1 answer
  • What function would you use to find the mean in a Microsoft excel document ?
    6·2 answers
  • If the computer has an encrypted drive, a ____ acquisition is done if the password or passphrase is available. a. passive b. sta
    8·1 answer
  • Which communication technology should you use if you need to connect three offices which are all within 3 miles of each other at
    6·1 answer
  • While the names for Web addresses, or URLs, are not case-sensitive, the names for files you create for the Web are. 
    11·1 answer
  • Cual es la fiabilidad de la innovacion tecnologica
    15·1 answer
  • In dos operating system ,write a command to delete the directory as well as the files of the directory ''world'' on drive E.
    15·1 answer
  • Write a function endpoints that takes a list of numbers (eg. [5, 10, 15, 20, 25]) and returns a new list of only the first and l
    15·1 answer
  • Identify 5 internal and external hardware components of a server
    5·1 answer
  • You need to install Windows on a new computer. You also need to replace a motherboard in another computer, and both tasks need t
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!