Q6.
#include <iostream>
#include<string.h>
using namespace std;
// code to count the vowles
int main() {
// phrase
string phrase = "Controlling complexity in essence of computer programming.";
// use length function to get the length of the string
int len = phrase.length();
// intitialize the variable count_vowel to store the count
int count_vowel = 0;
// now loop through each character in the string and check if they are vowels or not
for(int i = 0; i < len; i++) {
// if the character is vowels then add 1 to count_vowel
if (tolower(phrase[i]) == 'a' || tolower(phrase[i]) == 'e' || tolower(phrase[i]) == 'i' || tolower(phrase[i]) == 'o' || tolower(phrase[i]) == 'u') {
count_vowel += 1;
}
}
// display the result
cout << "following phrase: " << phrase << endl;
cout << "has " << count_vowel << " vowels." << endl;
return 0;
}

Q7.
// function to output the result of xor of A and B
/// input is bool values A and B
// output is a bool A xor B
bool bool_xor(bool A, bool B) {
// if the both inputs are same we return false
if (A == B) {
return false;
}
// else we return true
return true;
}
Q8.
// function to swap the character in the array
// input are: a characyer array, int i and int j
// function outputs nothing
void swap_char(char a[], int i, int j) {
// store the element at ith position in variable c
char c = a[i];
// now copy the jth element to ith position
a[i] = a[j];
// now assign c to jth position
a[j] = c;
}
Q9.
// function to reverse the string using the swap char function
// inputs are char array and length of array
// output is nothing
void reverseString(char s[], int len) {
// initialize j
int j = len-1;
// loop from start to middle of the string
for(int i = 0; i < len / 2; i++) {
// call function to swap the characters
swap_char(s, i, j-i);
}
}
"Controlling complexity is the essence of computer programming." Write a program that uses the C++ string...
Write a program that prompts the user to input a string. The program then uses the function substr to remove all the vowels from the string. For example, if str=”There”, then after removing all the vowels, str=”Thr”. After removing all the vowels, output the string. Your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel. #include <iostream> #include <string> using namespace std; void removeVowels(string& str); bool isVowel(char ch);...
Write a C++ program that will count the number of words and vowels in a sentence. Create a bool function called isVowel that accepts a character as a parameter and returns a true if it’s a vowel (aeiou) and false otherwise. Create an int function named countVowels that will accept a string variable as a parameter and will return the number of vowels in it. Call the isVowel function as part of this process. Write an int function named countWords...
‘C’ programming language question Write a MENU DRIVEN program to A) Count the number of vowels in the string B) Count the number of consonants in the string C) Convert the string to uppercase D) Convert the string to lowercase E) Display the current string X) Exit the program The program should start with a user prompt to enter a string, and let them type it in. Then the menu would be displayed. User may enter option in small case...
C++ programming language Write a program that contains following function: A function that receives a string of character, the function returns the number of letter c's or C's in the string the function receives
Write a C/C++ program that simulate a menu based binary number calculator. This calculate shall have the following three functionalities: Covert a binary string to corresponding positive integers Convert a positive integer to its binary representation Add two binary numbers, both numbers are represented as a string of 0s and 1s To reduce student work load, a start file CSCIProjOneHandout.cpp is given. In this file, the structure of the program has been established. The students only need to implement the...
LANGUAGE = C i. Write a program that takes int numbers from user until user gives a sentinel value (loop terminating condition). Sort the numbers in ascending order using Insertion sort method. Sorting part should be done in different function named insertionSort(). Your code should count the number of swaps required to sort the numbers. Print the sorted list and total number of swaps that was required to sort those numbers. (4 marks) ii. In this part take another number...
c++ #include <iostream> #include <string> using namespace std; /* Write a function checkPrime such that input: an int output: boolean function: Return true if the number is a prime number and return false otherwise */ //TO DO ************************************** /* Write a function checkPrime such that input: an array of int and size of array output: nothing function: Display the prime numbers of the array */ //TO DO ************************************** /* Write a function SumofPrimes such that input: an int output: nothing...
Write a method called printReverse() that
takes a string and uses recursion to print the contents of the
string in reverse order. The string itself should
not be reversed; it must be left in its
original form.
The method has the following header:
void printReverse(String s, int i)
where s is a reference to the string, and i is an integer
parameter that you may use as you see fit. You do not need
to code up this method as...
in c++
Program 1 Write a program that sorts a vector of names alphabetically using the selection sort and then searches the vector for a specific name using binary search. To do that, you need to write three functions I. void selSort (vector string &v: sorts the vector using selection sort 2. void display (const vector <string & v): displays the vector contents . int binSearch (const vector <ing& v, string key): searches the vector for a key returns the...
Write a C++ program to fill a vector with 5000 random numbers.
Then display:
The smallest number
The largest number
The number of odd values
The number of even values
The total of the values
The average of the values
Ask the user for an integer and display the subscript of the
cell where it was found or NOT FOUND! if it isn’t found.
There is a file called "Activity 25 Sort functions.zip" under
Materials in this week’s module. Download...