Using C and codeblocksSolutioninclude include include using

Using C++ and codeblocks:

Solution

#include <iostream>
#include <cstring>
#include <cctype>
using namespace std;

// complete the function count_and_print.
// the function will receive the variables st, vowels and ct.
// the function must count and print the number of lower case vowels (aeiou)
// in the string st. Use strlen and nested loops.

void count_and_print( char st[],int& ch,char vowels[])

{

for(int i=0;i<strlen(st);i++)
{
for(int j=0;j<strlen(vowels);j++)
{
if(st[i]==vowels[j])
ch++;
}
}

}

int main()
{


char st[25] = \" this is a sentence. \";
char vowels[] = \"aeiou\";
int ct = 0;

// call the function count_and_print
count_and_print(st,ct,vowels);
cout<<\"Count of vowels is \"<<ct;

return 0;

}

==================================================================

akshay@akshay-Inspiron-3537:~/Chegg$ g++ strinvowel.cpp
akshay@akshay-Inspiron-3537:~/Chegg$ ./a.out
Count of vowels is 6

Using C++ and codeblocks:Solution#include <iostream> #include <cstring> #include <cctype> using namespace std; // complete the function count_

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site