Help answer Questions in C++ 14. Create a function that swaps the values of the two inputs; it should do so as a pass by reference. 15. Create a function that returns the max of two numbers. 16. Create a function that rolls a dice named ROLL. It should create a random number between 1 and 6. Create another function that rolls two dice and says SNAKE EYES if you both rolls are a 1. Call these functions until you get snake eyes. Count how many times this happens. (Suggested to use a "static" variable for counting.)
Dear Student ,
As per the requirement submitted above , kindly find the below solution.
Question 14:
Here a new C++ program with name "main.cpp" is created, which contains following code.
main.cpp :
//c++ program to swap two numbers
#include <iostream> //header files
using namespace std;
void swap(int &,int &);//function prototype
int main() //main method
{
int num1, num2;//declaring variables
cout<<"Enter number 1 :";//asking num1
cin>>num1;//reading num1
cout<<"Enter number 2 :";//asking num2
cin>>num2;//reading num2
//printing value of num1 and num2 before swapping
cout<<"Value of num1 and num2 before
swapping"<<endl;
cout<<"num1 : "<<num1<<", num2 :
"<<num2<<endl;
swap(num1,num2);//calling function
//printing value of num1 and num2 after swapping
cout<<"Value of num1 and num2 after
swapping"<<endl;
cout<<"num1 : "<<num1<<", num2 :
"<<num2;
return 0;
}
//function defination
void swap(int &a,int &b)
{
int temp;//declaring temp variable
temp=a;
a=b;
b=temp;
}
======================================================
Output : Compile and Run main.cpp to get the screen as shown below
Screen 1 :main.cpp

******************************
Question 2:
main.cpp :
//c++ program that returns max to two number
#include <iostream>//header files
using namespace std;
int findmax(int,int);//function prototype
//main method
int main()
{
int num1, num2;//declaring variables
cout<<"Enter number 1 : ";//asking num1
cin>>num1;//reading num1
cout<<"Enter number 2: ";//asking num2
cin>>num2;//reading num2
//print Maximum
cout<<"Maximum of "<<num1<<" and
"<<num2<<" is : "<<findmax(num1,num2);
return 0;
}//function defination
int findmax(int num1,int num2)
{
int max;//declaring variable to store max
//checking numbers
if(num1>num2)
{
max=num1;
}
else
{
max=num2;
}
//return max
return max;
}
============================================
output :
Screen 1:

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.
Help answer Questions in C++ 14. Create a function that swaps the values of the two...
In c++ Create a function called Switch_Them that swaps the values of the two inputs; it should do so as a pass by reference.
Use Python: Dice Rolls Create a function named build_roll_permutations which returns all 36 permutations of rolling two six sided dice. That is, each dice has a number 1 through 6 on one of its sides. The return value is a list which contains tuples. Each tuple represents a possible dice roll of two dice. Card Deck Create a function named build_deck that returns a full deck of cards. The cards are created by a rank and a suit (e.g. 2♡)....
Please write the code using matlab
1) i. Create an anonymous function named optimist, that accepts a single variable as input i Create a row vector Tthat represents the number of seconds in two minutes, starting ii. Call the function optimist on the vector T, store the result in variable R1 and returns the double of that variable from one and ending at a hundred and twenty v. Create an anonymous function named pessimist, that accepts a single variable as...
can someone help me with this C++ problem write your game() function and 3+ functions that simulate the game of Jeopardy Dice according to the following game mechanics and specifications. Game Mechanics There are two players: the user and the computer, who alternate turns until one of them reaches 80 points or higher. The user is always the first player and starts the game. If any player reaches 80 points or more at the end of their turn, the game...
in C++ answer question Create a function named Poland that returns 10 times whatever the input was. Call this function from main in a for loop 25 times, pass in "i" each time.
WITHOUT FUNCTIONS. Could anyone help me solve this problem not using the function ? Thanks a lot. Pig Dice Game Pig is a simple two player dice game, played with one die. The first player to reach or surpass 50 is the winner. Each player takes a turn rolling the dice. They add to the pot with each roll, having to decide to roll again and increase the pot, or cash out. The risk being they could lose the amount...
c++ please help Create two arrays of 20 elements, called myArray1 and myArray2 Create a function randBetween that returns an integer between 2 integer inputs (int randBetween(int min, int max)); Fill the myArray1 with the random values. Loop thru the myArray1 and find the difference between the element i and element i + 1; put that difference in array2 example: array1 = {1, 3, 4, 5} array2 ends up having {-2, -1, -1} Loop thru myArray1 and find the min...
Please i need helpe with this JAVA code. Write a Java program simulates the dice game called GAMECrap. For this project, assume that the game is being played between two players, and that the rules are as follows: Problem Statement One of the players goes first. That player announces the size of the bet, and rolls the dice. If the player rolls a 7 or 11, it is called a natural. The player who rolled the dice wins. 2, 3...
Please help with this question (the two functions). I've attempted it but it's not working. We have to complete the 2 functions int largest(int * x); and void display(int *arr); (one prints the values in array and the other gets max value in array). But we can only use pointer indirection and address arithmetic to access and traverse the array. No array index [] should be used in the functions. C PROGRAMMING: ----------------- /* Passing an array to a function....
PROJECT TASKS 1. Read the problem definition below and write a C++ program that implements your solution. Readability of the program will be graded based on variable naming, indentation, commenting (not too little and not too much), spacing, consistency, and styling in general including choice of functions. [NOTE: the code at the end of this document does not completely meet requirements as it uses many single letter variables and has no internal documentation. You need to improve it.] 2. Compile...