Write a function def countVowels(string) that returns a count of all vowels in t
ID: 3680382 • Letter: W
Question
Write a function def countVowels(string) that returns a count of all vowels in the string string. Vowels are the letters a, e, i, o, and u, and their uppercase variants. Write a function def countWords(string) that returns a count of all words in the string string. Words are separated by spaces. For example, countWords("Mary had a little lamb) should return 5. It is a well-known phenomenon that most people are easily able to read a text whose words have two characters flipped, provided the first and last letter of each word are not changed. For example, I don't give a damn for a man that can only spell a word one way. (MrakTaiwn) Write a function scraable(word) that constructs a scrambled version of a given word, randomly flipping two characters other than the first and last one. Then write a program that reads words and prints the scrambled words. Write functions def sphereVolume(r) def sphereSurface(r) def cylinderVolume(r, h) def cylinderSurface(r. h) def coneVoluroe(r, h) def coneSurface(r, h) that compute the volume and surface area of a sphere with radius r, a cylinder with a circular base with radius r and height h, and a cone with a circular base with radius r id height h. Then write a program that prompts the user for the values of r and h, calls the six functions, and prints the results. Write a function def readFloat(prompt) th.it displays the prompt string, followed by a space, reads a floating-point number in, and returns it. Here is a typical usage: salary - readFloat("Please enter your salary:") percentageRaise - readFloat("What percentage raise would you like?")Explanation / Answer
P5.6 Programme:
// C program to find vowels in the given string
#include<stdio.h>
void main()
{
char str[50];
int vowels = 0, i = 0;
printf("Enter any String:");
scanf("%s",str);
while(str[i] != '')
{
if(str[i]=='A' || str[i]=='a' || str[i]=='E' || str[i]=='e' || str[i]=='I' || str[i]=='i' || str[i]=='O' || str[i]=='o' || str[i]=='U' || str[i]=='u')
vowels++;
i++;
}
printf(" The Total Number of Vowels are: %d ", vowels);
}
Output:
Enter any String: Apple The Total Number of Vowels are: 2
P5.7 Programme:
// C program to find no. of words in the given sentense
#include <stdio.h>
void main()
{
char s[50],ch;
int i,c=0;
printf("Enter any sentense : ");
for(i=0;ch!=' ';i++){
ch=getchar();
s[i]=ch;
}
s[i]='';
for(i=0;s[i]!='';i++)
{
if(s[i]==' ')
{
c++;
while(s[i]==' ')
i++;
}
}
printf(" Total words in the given sentense are: %d ",c+1);
}
Output:
Enter any sentense : This is c programming language
Total words in the given sentense are: 5
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.