Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is a question for C++ and solved by coding a program in Dev++ Write a pass

ID: 3598110 • Letter: T

Question

This is a question for C++ and solved by coding a program in Dev++

Write a pass by value function to triple an integer value. Also create a main method to call this method four times, once with a literal, once with a variable, once with a mathematical expression and once using the pow function. Copy your program and output into the answer for the Discussion Board. This is a question for C++ and solved by coding a program in Dev++

Write a pass by value function to triple an integer value. Also create a main method to call this method four times, once with a literal, once with a variable, once with a mathematical expression and once using the pow function. Copy your program and output into the answer for the Discussion Board. This is a question for C++ and solved by coding a program in Dev++

Write a pass by value function to triple an integer value. Also create a main method to call this method four times, once with a literal, once with a variable, once with a mathematical expression and once using the pow function. Copy your program and output into the answer for the Discussion Board. This is a question for C++ and solved by coding a program in Dev++

Write a pass by value function to triple an integer value. Also create a main method to call this method four times, once with a literal, once with a variable, once with a mathematical expression and once using the pow function. Copy your program and output into the answer for the Discussion Board.

Explanation / Answer

Given below is the code with output. Please do rate the answer if it helped. Thank you.

#include <iostream>
#include <cmath> //for pow()
using namespace std;
int triple(int n); //a function receiving an int by pass by value and returns the triple of n i.e 3 times the number
int main()
{
//passing a literal to triple()
cout << "Triple of 3 = " << triple(3) << endl;;
  
//passing a variable to triple()
int x = 5;
cout << "Triple of " << x << " = " << triple(x) << endl;
  
//using a mathematical expression as an argument for triple()
cout << "x = " << x << endl;
cout << "Triple of mathematical expression x * 2 + 6 = " << triple(x * 2 + 6) << endl;
  
  
//using pow() function as an arguemnt to triple()
cout << "Triple of pow(2, 2) is " << triple(pow(2,2)) << endl; //pow(2, 2) is 4 and triple(pow(2,2)) becomes triple(4) = 12
  
}

int triple(int n)
{
return 3 * n;
}

output

Triple of 3 = 9
Triple of 5 = 15
x = 5
Triple of mathematical expression x * 2 + 6 = 48
Triple of pow(2, 2) is 12
Program ended with exit code: 0

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote