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
Phân tích cạnh tranh của cocacola và pepsi
Fittoniya [83]
I don’t understand please speak English
7 0
2 years ago
What are the five types of alignment in word?
valentinak56 [21]
I know of four,
Left-aligned
Center-aligned
right-aligned
justified

5 0
3 years ago
Read 2 more answers
What are the factors affecting the life of ballast? Explain.​
Nady [450]

Answer:

When it's too hot or too cold.

Explanation:

When a bulb of the wrong size or voltage is used in the fixture, the ballast often overheats, causing the light to shut off. The bulbs and the fixture must also match in frequency, or the ballast becomes overworked and overheated.

7 0
3 years ago
Designations at the end of file names such as .docx and .html are called
Amanda [17]

Answer:

Designations at the end of file names such as .docx and .html are called. File extensions.

Explanation:

7 0
3 years ago
ShellShock had the potential for an unauthorized user to gain access to a server. It affected many internet-facing services, whi
mina [271]

Answer: Windows

Explanation:

ShellShock: Also called Bashdoor, it is a security bug which is found in the Bash shell of operating system e.g. Unix. It allows the hacker to execute scripts and commands by gaining unauthorized access. This affects many machines, devices that use Bash. Servers like web servers are most affected as most of them run Unix based OS like OS X. Most vulnerable are those who use Unix or Linux operating systems.  

Microsoft Windows does not use Bash so it does not directly affect Windows os. For those who are using Windows PC, Windows phones and websites that are developed by MS software are non-vulnerable to ShellShock.

4 0
2 years ago
Other questions:
  • Uses computers resources from multiple locations to solve ​
    13·2 answers
  • When using color in computer-generated presentation aids, you should use?
    10·1 answer
  • Select a classification for File2 so that: Alice can read and write to File2 Bob and Charlie can write to File2, but can't read
    6·1 answer
  • What is the least number of bits you would need to borrow from the network portion of a Class B subnet mask to get at least 130
    10·1 answer
  • Select all the sets that are countably infinite. Question 3 options: the set of real numbers between 0.1 and 0.2 the set of all
    12·1 answer
  • An organization's Finance Director is convinced special malware is responsible for targeting and infecting the finance departmen
    13·1 answer
  • Which is an example of an operating system? (5 points)
    5·1 answer
  • Which letter shows the ball when it has the maximum kinetic energy
    15·1 answer
  • Why does a computer need memory​
    15·2 answers
  • Web résumés allow you to include extra graphics and images that you would not include in a traditional résumé. Please select the
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!