Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | Apr 2017 |
Last Sign in: | 12 Weeks Ago, 6 Days Ago |
Questions Answered: | 4870 |
Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
The following C program prompts the user and reads in a line of text, then displays the text. /**
* A simple C program that prompts the user
* for a line of text.
*
* @author
*/
#include <stdio.h>
#include <string.h>
#define LEN 256
void getPhrase (char phrase[])
{
printf ("Enter a phrase : ");
fgets (phrase, LEN, stdin);
}
void reportPhrase (char phrase[])
{
int i = 0;
for (i = 0; i < strlen (phrase); i++)
{
printf ("%c", phrase[i]);
}
}
int main (int argc, char *argv[])
{
char phrase[LEN];
getPhrase (phrase);
reportPhrase (phrase);
}
It is worth familiarizing yourself with the basic fundamentals of C when looking at this simple program as it will provideAssignment This assignment will involve reading in a line of text, and generating a histogram of the vowels that occur in the text (you will edit the program supplied above, adding the code to generate the histogram).
For example, if the user entered
Alphabet soup is my favorite soup in the whole world
your program would report
a: * * * e: * * * * i: * * * o: * * * * * u: * *
Notice that it is case-insensitive. If the user entered
Tomato TOO.
your program would report
a: * e: i: o: * * * * u:
There are many different simple ways you can write this program, and I want you to experiment with your own ideas. Your program must work correctly with any text entered by the user.
What to submit On a terminal window, compile and run the program. As input, enter the phrase “My name is […]” substituting […] with your first and last name. Then take a screen shot. Make sure the screen shot shows the gcc command, the ./a2 command, the input phrase and the result(vowel histogram).