PLEASE ANSWER ALL OF THE FOLLOWING QUESTIONS IN CTT PROGRAMMING THANK YOU Questi
ID: 3770112 • Letter: P
Question
PLEASE ANSWER ALL OF THE FOLLOWING QUESTIONS IN CTT PROGRAMMING THANK YOU
Question 5
Write a program that contains and uses a function called tripleNum. void tripleNum(int&); This function utilize a call by reference. The function get an argument n and multiply it by 3. The program ask for a number a, pass it on as an argument for tripleNum(), and print the result of tripleNum(int& entry) on the entry.
Question 6
Using vectors, write a program that asks a user to enter a word, saves that word into a vector and prints out the the console:
- vowels in the entered word
- consonants in the entered word
Tips: focus on the vowels; everything else becomes consonant.
Question 7
Complete (add onto this code) the missing expressions/lines of code, to display the words: jewelry stones cabbage knees owls toy-like lice
Q_pointers.cpp Submit your working code.
Question 8
Consider the following constructor:
student (string n, int k)
{
name = n;
no_of_tests = k;
marks = new double [k];
for(int i = 0; i<k; i++)
{
cout << " Enter grade #: "<< i << endl;
cin >> marks[i];
}
Write a destructor for the constructor above.
Explanation / Answer
Question 6:
void tripleNum(int &x)
{
x=x*3;
return;
}
#include <iostream>
using namespace std;
// function declaration
void tripleNum(int &x);
int main ()
{
// local variable declaration:
int a = 100;
cout << "Before triple, value of a :" << a << endl;
/* calling a function to swap the values using variable reference.*/
tripleNum(a);
cout << "After tripleNum, value of a :" << a << endl;
return 0;
}
Question 8:
~student(){
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.