Write a recursive C function that counts the number of vowels in a str.docx

D

Write a recursive C function that counts the number of vowels in a string. You may wish to call the is_element function. Solution #include <string.h> int vowels(char *str,int count) { if(!*str) return count; char ch=lower(*str); int match=ch==\'a\' || ch==\'e\' || ch==\'i\' || ch==\'o\' || ch==\'u\'; return vowels(++str, count+match); } int main(void) { int i,t, pom; char str[30]; scanf(\"%d\", &t); for(i=0;i<t;i++) { scanf(\"%29s\", str); pom=vowels(str,0) printf(\"%d\ \", pom); } return 0; } .

Write a recursive C function that counts the number of vowels in a string. You may wish to call
the is_element function.
Solution
#include <string.h>
int vowels(char *str,int count)
{
if(!*str)
return count;
char ch=lower(*str);
int match=ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u';
return vowels(++str, count+match);
}
int main(void)
{
int i,t, pom;
char str[30];
scanf("%d", &t);
for(i=0;i<t;i++)
{
scanf("%29s", str);
pom=vowels(str,0)
printf("%d ", pom);
}
return 0;
}

Recommended

Write a SIMPLE java program to print out the numbers from 100 to 1- wi.docx by
Write a SIMPLE java program to print out the numbers from 100 to 1- wi.docxWrite a SIMPLE java program to print out the numbers from 100 to 1- wi.docx
Write a SIMPLE java program to print out the numbers from 100 to 1- wi.docxdrosa1
31 views2 slides
Write a simple c++ program that computes the value of ex by using the.docx by
Write a simple c++ program that computes the value of ex by using the.docxWrite a simple c++ program that computes the value of ex by using the.docx
Write a simple c++ program that computes the value of ex by using the.docxdrosa1
12 views1 slide
Write a short assembly language module to be used with C++ that rotate.docx by
Write a short assembly language module to be used with C++ that rotate.docxWrite a short assembly language module to be used with C++ that rotate.docx
Write a short assembly language module to be used with C++ that rotate.docxdrosa1
2 views2 slides
Write a short essay- between 400 and 500 words- responding to the assi.docx by
Write a short essay- between 400 and 500 words- responding to the assi.docxWrite a short essay- between 400 and 500 words- responding to the assi.docx
Write a short essay- between 400 and 500 words- responding to the assi.docxdrosa1
3 views1 slide
Write a SELECT statement that returns the LastName and JobTitle of eac.docx by
Write a SELECT statement that returns the LastName and JobTitle of eac.docxWrite a SELECT statement that returns the LastName and JobTitle of eac.docx
Write a SELECT statement that returns the LastName and JobTitle of eac.docxdrosa1
6 views1 slide
Write a routine to reconstruct the shortest paths from the algorithm i.docx by
Write a routine to reconstruct the shortest paths from the algorithm i.docxWrite a routine to reconstruct the shortest paths from the algorithm i.docx
Write a routine to reconstruct the shortest paths from the algorithm i.docxdrosa1
4 views2 slides

More Related Content

More from drosa1

Write a query to display the customer last name and city for all custo.docx by
Write a query to display the customer last name and city for all custo.docxWrite a query to display the customer last name and city for all custo.docx
Write a query to display the customer last name and city for all custo.docxdrosa1
3 views2 slides
write a program that reads package weights and calculate the post fee.docx by
write a program that reads package weights and calculate the post fee.docxwrite a program that reads package weights and calculate the post fee.docx
write a program that reads package weights and calculate the post fee.docxdrosa1
2 views2 slides
Write a program that takes an input of n and prints the numbers from 1.docx by
Write a program that takes an input of n and prints the numbers from 1.docxWrite a program that takes an input of n and prints the numbers from 1.docx
Write a program that takes an input of n and prints the numbers from 1.docxdrosa1
2 views2 slides
Write a program to compute the volume V of a cylinder of radius r and (1).docx by
Write a program to compute the volume V of a cylinder of radius r and (1).docxWrite a program to compute the volume V of a cylinder of radius r and (1).docx
Write a program to compute the volume V of a cylinder of radius r and (1).docxdrosa1
2 views1 slide
Write a program in assembly language that will test PIN #0 of PORTA to.docx by
Write a program in assembly language that will test PIN #0 of PORTA to.docxWrite a program in assembly language that will test PIN #0 of PORTA to.docx
Write a program in assembly language that will test PIN #0 of PORTA to.docxdrosa1
4 views2 slides
Write a program that uses a dynamic array that contains 5 items of dou (1).docx by
Write a program that uses a dynamic array that contains 5 items of dou (1).docxWrite a program that uses a dynamic array that contains 5 items of dou (1).docx
Write a program that uses a dynamic array that contains 5 items of dou (1).docxdrosa1
2 views1 slide

More from drosa1(20)

Write a query to display the customer last name and city for all custo.docx by drosa1
Write a query to display the customer last name and city for all custo.docxWrite a query to display the customer last name and city for all custo.docx
Write a query to display the customer last name and city for all custo.docx
drosa13 views
write a program that reads package weights and calculate the post fee.docx by drosa1
write a program that reads package weights and calculate the post fee.docxwrite a program that reads package weights and calculate the post fee.docx
write a program that reads package weights and calculate the post fee.docx
drosa12 views
Write a program that takes an input of n and prints the numbers from 1.docx by drosa1
Write a program that takes an input of n and prints the numbers from 1.docxWrite a program that takes an input of n and prints the numbers from 1.docx
Write a program that takes an input of n and prints the numbers from 1.docx
drosa12 views
Write a program to compute the volume V of a cylinder of radius r and (1).docx by drosa1
Write a program to compute the volume V of a cylinder of radius r and (1).docxWrite a program to compute the volume V of a cylinder of radius r and (1).docx
Write a program to compute the volume V of a cylinder of radius r and (1).docx
drosa12 views
Write a program in assembly language that will test PIN #0 of PORTA to.docx by drosa1
Write a program in assembly language that will test PIN #0 of PORTA to.docxWrite a program in assembly language that will test PIN #0 of PORTA to.docx
Write a program in assembly language that will test PIN #0 of PORTA to.docx
drosa14 views
Write a program that uses a dynamic array that contains 5 items of dou (1).docx by drosa1
Write a program that uses a dynamic array that contains 5 items of dou (1).docxWrite a program that uses a dynamic array that contains 5 items of dou (1).docx
Write a program that uses a dynamic array that contains 5 items of dou (1).docx
drosa12 views
Write a program that calculates the final value of a ten year- $10-000 (1).docx by drosa1
Write a program that calculates the final value of a ten year- $10-000 (1).docxWrite a program that calculates the final value of a ten year- $10-000 (1).docx
Write a program that calculates the final value of a ten year- $10-000 (1).docx
drosa12 views
Write a program that finds the temperature- as an integer - that is th.docx by drosa1
Write a program that finds the temperature- as an integer - that is th.docxWrite a program that finds the temperature- as an integer - that is th.docx
Write a program that finds the temperature- as an integer - that is th.docx
drosa12 views
Write a python program that opens the career-txt file that is included.docx by drosa1
Write a python program that opens the career-txt file that is included.docxWrite a python program that opens the career-txt file that is included.docx
Write a python program that opens the career-txt file that is included.docx
drosa12 views
Write a program that contains and utilizes a function called haltNum(i.docx by drosa1
Write a program that contains and utilizes a function called haltNum(i.docxWrite a program that contains and utilizes a function called haltNum(i.docx
Write a program that contains and utilizes a function called haltNum(i.docx
drosa12 views
Write a program in MATLAB to implement the algorithm of Gaussian Elimi.docx by drosa1
Write a program in MATLAB to implement the algorithm of Gaussian Elimi.docxWrite a program in MATLAB to implement the algorithm of Gaussian Elimi.docx
Write a program in MATLAB to implement the algorithm of Gaussian Elimi.docx
drosa13 views
write a program to calculate the average of six number input by the us.docx by drosa1
write a program to calculate the average of six number input by the us.docxwrite a program to calculate the average of six number input by the us.docx
write a program to calculate the average of six number input by the us.docx
drosa17 views
Write a program that uses the DrawingPanel to produces the following f.docx by drosa1
Write a program that uses the DrawingPanel to produces the following f.docxWrite a program that uses the DrawingPanel to produces the following f.docx
Write a program that uses the DrawingPanel to produces the following f.docx
drosa12 views
Write a program in assembly language 8086 not 8085 to find the number.docx by drosa1
Write a program in assembly language 8086 not 8085 to find the number.docxWrite a program in assembly language 8086 not 8085 to find the number.docx
Write a program in assembly language 8086 not 8085 to find the number.docx
drosa17 views
write a mips code which pop-ups a confirmation dialog which have yes o.docx by drosa1
write a mips code which pop-ups a confirmation dialog which have yes o.docxwrite a mips code which pop-ups a confirmation dialog which have yes o.docx
write a mips code which pop-ups a confirmation dialog which have yes o.docx
drosa110 views
Write a program in (C or C++ or Java or python) to capture the center.docx by drosa1
Write a program in (C or C++ or Java or python) to capture the center.docxWrite a program in (C or C++ or Java or python) to capture the center.docx
Write a program in (C or C++ or Java or python) to capture the center.docx
drosa12 views
write a new equation of the line in slope intercept form parallel to e.docx by drosa1
write a new equation of the line in slope intercept form parallel to e.docxwrite a new equation of the line in slope intercept form parallel to e.docx
write a new equation of the line in slope intercept form parallel to e.docx
drosa15 views
Write a program file_max-c that reads a set of integer numbers from a.docx by drosa1
Write a program file_max-c that reads a set of integer numbers from a.docxWrite a program file_max-c that reads a set of integer numbers from a.docx
Write a program file_max-c that reads a set of integer numbers from a.docx
drosa13 views
Write a PHP function (write the function only) to dynamically create a.docx by drosa1
Write a PHP function (write the function only) to dynamically create a.docxWrite a PHP function (write the function only) to dynamically create a.docx
Write a PHP function (write the function only) to dynamically create a.docx
drosa13 views
Write a PASCAL program to compare two integers entered from the keyboa.docx by drosa1
Write a PASCAL program to compare two integers entered from the keyboa.docxWrite a PASCAL program to compare two integers entered from the keyboa.docx
Write a PASCAL program to compare two integers entered from the keyboa.docx
drosa155 views

Recently uploaded

EIT-Digital_Spohrer_AI_Intro 20231128 v1.pptx by
EIT-Digital_Spohrer_AI_Intro 20231128 v1.pptxEIT-Digital_Spohrer_AI_Intro 20231128 v1.pptx
EIT-Digital_Spohrer_AI_Intro 20231128 v1.pptxISSIP
407 views50 slides
The basics - information, data, technology and systems.pdf by
The basics - information, data, technology and systems.pdfThe basics - information, data, technology and systems.pdf
The basics - information, data, technology and systems.pdfJonathanCovena1
156 views1 slide
Classification of crude drugs.pptx by
Classification of crude drugs.pptxClassification of crude drugs.pptx
Classification of crude drugs.pptxGayatriPatra14
104 views13 slides
Volf work.pdf by
Volf work.pdfVolf work.pdf
Volf work.pdfMariaKenney3
66 views43 slides
JQUERY.pdf by
JQUERY.pdfJQUERY.pdf
JQUERY.pdfArthyR3
96 views22 slides
unidad 3.pdf by
unidad 3.pdfunidad 3.pdf
unidad 3.pdfMarcosRodriguezUcedo
122 views38 slides

Recently uploaded(20)

EIT-Digital_Spohrer_AI_Intro 20231128 v1.pptx by ISSIP
EIT-Digital_Spohrer_AI_Intro 20231128 v1.pptxEIT-Digital_Spohrer_AI_Intro 20231128 v1.pptx
EIT-Digital_Spohrer_AI_Intro 20231128 v1.pptx
ISSIP407 views
The basics - information, data, technology and systems.pdf by JonathanCovena1
The basics - information, data, technology and systems.pdfThe basics - information, data, technology and systems.pdf
The basics - information, data, technology and systems.pdf
JonathanCovena1156 views
Classification of crude drugs.pptx by GayatriPatra14
Classification of crude drugs.pptxClassification of crude drugs.pptx
Classification of crude drugs.pptx
GayatriPatra14104 views
JQUERY.pdf by ArthyR3
JQUERY.pdfJQUERY.pdf
JQUERY.pdf
ArthyR396 views
A-Level Art by WestHatch
A-Level ArtA-Level Art
A-Level Art
WestHatch48 views
GCSE Geography by WestHatch
GCSE GeographyGCSE Geography
GCSE Geography
WestHatch47 views
Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant... by Ms. Pooja Bhandare
Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant...Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant...
Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant...
Ms. Pooja Bhandare166 views
How to empty an One2many field in Odoo by Celine George
How to empty an One2many field in OdooHow to empty an One2many field in Odoo
How to empty an One2many field in Odoo
Celine George97 views
Monthly Information Session for MV Asterix (November) by Esquimalt MFRC
Monthly Information Session for MV Asterix (November)Monthly Information Session for MV Asterix (November)
Monthly Information Session for MV Asterix (November)
Esquimalt MFRC91 views
Pharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptx by Ms. Pooja Bhandare
Pharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptxPharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptx
Pharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptx
Ms. Pooja Bhandare120 views
AUDIENCE - BANDURA.pptx by iammrhaywood
AUDIENCE - BANDURA.pptxAUDIENCE - BANDURA.pptx
AUDIENCE - BANDURA.pptx
iammrhaywood131 views
When Sex Gets Complicated: Porn, Affairs, & Cybersex by Marlene Maheu
When Sex Gets Complicated: Porn, Affairs, & CybersexWhen Sex Gets Complicated: Porn, Affairs, & Cybersex
When Sex Gets Complicated: Porn, Affairs, & Cybersex
Marlene Maheu99 views

Write a recursive C function that counts the number of vowels in a str.docx

  • 1. Write a recursive C function that counts the number of vowels in a string. You may wish to call the is_element function. Solution #include <string.h> int vowels(char *str,int count) { if(!*str) return count; char ch=lower(*str); int match=ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u'; return vowels(++str, count+match); } int main(void) { int i,t, pom; char str[30]; scanf("%d", &t); for(i=0;i<t;i++) {