Write a program with an additional function called subtract2Function. Your main function will ask the user to enter an integer. Then, it will call subtract2Function, passing the value of the integer to it. The subtract25Function will, as you might guess, subtract 2 from that integer. Then, the subtract2Function will display a message saying your number is now equal to . List the new function's prototype before the main function. LIST THE ENTIRE PROGRAM BELOW.
Q: tNode class, define the IndexOf() function to return -1 if not found. rst index after the head node…
A: Approach is:- Step-1:-We will implement a linked list uisng class. Step-2:- We will ask user to…
Q: Write a program which ends when a user types a user- defined letter. 1. Get an english letter as a…
A: function main(): Start Declare terminate, user_input Display "Pick an english letter to terminate:…
Q: The author of this program wanted Vote! displayed three times on separate lines. What are the…
A: Changes needed in the code: The increment statement is missing in the “While” loop. The given loop…
Q: Programming Assignment #10 Given the IntNode class, define the FindMax() function to return the…
A: It is defined as a general-purpose programming language and is widely used nowadays for competitive…
Q: Binary search can be implemented as a recursive algorithm. Each call makes a recursive call on…
A: The answer is written in step 2
Q: Write a class Point that represents a point in 3D cartesian coordinate system. Use Constructors or…
A: To calculate distance: (x2-x1)2+(y2-y1)2+(z2-z1)2 For point P1 distance: (x1,y1,z1) = (0,0,0) and…
Q: Write a do loop that reads integers and computes their sum. Stop when a zero is read or the when the…
A: #include <iostream> using namespace std; int main() { int previous; int sum=0; do{ int n; //…
Q: Q3: b- Write a program to exchange he main diagonal elements with the secondary diagonal elements of…
A: Here since the dimension is not specified, let's do this for 3x3 matrix. Square matrix means number…
Q: (The EvenNumber class) Define the EvenNumber class for representing an even number. The class…
A: We need to write a C++ code for the given scenario.
Q: QUESTION 5 (a) Write a program that represents a simple calculator using switch statement. • The…
A: Note: As requested we did Question 5 (a) in the C++ programming language Given, Requirements:…
Q: Q3: a- Write a program to pass a two dimensional square matrix as a parameter to a function; this…
A: Solution in c++
Q: 01 write the instruction to declaring about: i- integer x and y ii- floating point 1.233 iii-…
A: Objective: According to the given question, the instructions to declare several types of variables…
Q: * warm up2: returning value to main function create a program using the following pseudocode: you…
A: A welcome message is displayed to the user along with a menu showing user three choices they have:…
Q: (a) Write a program that computes the average of numbers using arrays. • The program should…
A: Write a program that computes the average number using the arrays using c++ programming language
Q: Factorial of a Number Write a C++ Program to find Factorial of a number using class. int main() is…
A: #include<iostream> using namespace std; class factorial { private:…
Q: Write a program that uses the recursive function to calculate GCD by using Euclid's algorithm. a)…
A: Editable code, code screenshot, sample output screenshot.
Q: Create a function that takes in number of guests. Ask the user to name of each guest and output…
A: C++ used to answer this question
Q: Q5: Continue with Point class: a) Copy the previous program to a new file. b) Overload [] operator,…
A: Solution: Given, int main() { Point a(3, 4); cout << a[0] << endl; // 3…
Q: 2. Write a C++ program to that computes the area of a triangle using Heron's formula. • Prompt the…
A: Code- #include<iostream> #include<math.h> using namespace std; int main() {…
Q: (b) Write a program that takes a string from the user and calculates the number of vowels,…
A: START DECLARE vowels = 0, consonants = 0, digits = 0, spaces = 0 PRINT "Enter a line of string: "…
Q: Good day! I am the proud owner of a mall that will soon be built in a town nearby. We plan on adding…
A: Step-1: Start Step-2: Declare a variable ch and take input from user Step-3: if ch is equal to 'm'…
Q: (Decimal to binary) Write a function that parses a decimal number into a binary number as a string.…
A: logic: - declare a blank string str="" while(n) { str += (n%2) + '0'; n /= 2; } Now use…
Q: |* create a program named currency converter.cpp use the following pseudocode to write the program:…
A: #include <iostream> #include<iomanip> using namespace std;double convertCanada(int…
Q: 5. Decimal Galore We've been dealing with integers too much, it's time for decimals to shine!…
A: NOTE: Code run successfully as above problem describe. Please follow my screenshot for no error.…
Q: (b) A triangle can be classified based on the lengths of its sides as equilateral. isosceles or…
A: Algorithm for the code: Step 1: Declare three sides of the triangle. Step 2: Enter three sides at…
Q: 06 Write expression to obtain: i- -5 <x <15 ii- -52 x2 15 iii- x < -5 and x = 13
A: C++ expression consists of operators, constants, and variables which are arranged according to the…
Q: 3. Write a program that recursively and iteratively counts down from n. a. Create a void recursive…
A: In the below code provided, the input function is used to request a value for n from the console.…
Q: UO wants a program that displays the amount of money charged for a seminar. The fee per person is…
A: #include<iostream>int main(){ using namespace std; int number =0; cout<<"Enter the…
Q: (c) You are required to create a program that reads a letter of the alphabet from the user. If the…
A: We want to check if the letter input is vowel or not, for y we have added a check, and printed…
Q: #include int main() { int i=7; do for(int j=7;j4); return 0;
A: Here, Program is given to tracing.
Q: (Algebra: solve 2 x 2 linear equations) You can use Cramer's rule to solve the following 2 x 2…
A: C++ program is given below for the following question we have to implement void solveEquation(…
Q: The cout statement in the following program segment will display 9: z = 10; cout << --z;
A: Pre decrement operator is an operator which decreases the value by 1 and the value in the stack gets…
Q: Write a complete C++ program that simulates rolls of a die. • The program will prompt the user for a…
A: Use srand() for generating various random numbers with respect to current time which generates…
Q: Gamification in Education: Explore how computer science is used to implement gamification in…
A: Gamification, the integration of game-like elements into non-game contexts, has emerged as a…
Q: The Strip Filter ow that you know a little bit about filters, let's use that technique with our N…
A: Given:
Q: Question: 2 Write a program using nested loop structures that displays the following ou tput. 00 01…
A: #Logic to develop code Let we have two variable i and j. variable i will print rows and variable j…
answer in c++
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
- Implement a function named get_player_selection. This function has parameters for the players number (which will be either 1 or 2), and the number of sticks remaining on the board. For this function you will need to do the following: Use the input function to get the player to type in their selection. Validate the user’s input, printing out a message if they enter an invalid number and continually prompting them until they do enter a valid number. The user may enter any number between 1 and 3, unless there are fewer than 3 sticks remaining, in which case they can only enter between 1 and the number of sticks remaining. As in the example, the input prompt should list the valid range of numbers. Return the (validated) number as an integer (not a string). You should test that this function works by running it in the REPL. Make sure you try different scenarios, like the user entering an invalid number multiple times in a row. After you are done testing and fixing any errors you find,…In this coding challenge, you will be retrieving email usernames from a string. You will write a function named get_usernames () that takes in a string as it's input parameter, and returns a list of email usernames in the string. The input strings will contain 0 or more emails in the format and the '@' symbol will only appear in the context of an email. The order of usernames should match the order in the input text. username@domainname, For example: EXAMPLE 1 text: "If you need help on an assignment, email help@ucsd.edu or support@gmail.com" return: ['help', 'support'] EXAMPLE 2 text: "Good morning! I hope you're having a great time with CSE 8A!" return: [] EXAMPLE 3 text: "I've been having a lot of trouble reaching you, can you please email me at cse@ucsd.edu? return: ['cse', 'cse'] Here is the problem description: Function Name: get_usernames Parameter: text - A string corresponding to a piece of text containing 0 or more emails. Return: A list of the email usernames in the input…Write a function called user_input() that takes an integer n as a parameter. Thisfunction should display the integer n to the user and prompt them to enter its equivalentbinary value (the user just has to make a guess here). Your function should return theuser input.
- Write a function, named randomPassword, that generates a random password that takes no parameter. It will return the randomly generated password as its ONLY result. Display the randomly generated password in the main program. Password Criteria: o The password should have a random length of between 7 and 10 characters. o Each character should be randomly selected from positions 33 to 126 from the ASCII table You must import randint function directly and inline within the random package and it must be the first line of code in your program, after your program header comment. o Declaring and using FOUR constants. Constants must be named appropriately and intuitively. o You must use the chr built-in function within your randomPassword function: o Declaring the main function and invoking randomPassword function. o Logical approach to problem solving, computation, and displaying appropriate output.Write a function that displays a message indicating the number of times it gets called: Forinstance "The function has been called three times". Write a program that calls this function 10 times from main (). You will need to use a global variable to store the count. A globalvariable is declared outside the main () function. Note: All variables declared inside a function are local variables. Their value is lost once the function ends.Complete the process_name() function that takes a single string parameter name. You can assume that the name will always be in the format first name surname with a single space character between the first name and the surname. The function returns a string consisting of the first letter of the first name followed by the first three letters of the surname. All of the characters in the returned string should be in lowercase. Some examples of the function being used are shown below: For example: Test Result print(process_name("Damir Azhar")) dazh print(process_name("Ann Cameron")) acam Answer: (penalty regime: 0 %) Reset answer 1v def process_name (name): 2
- Some of the earliest computer games developed were Interactive Fiction games, in which the user’s environment is described in text, and the user makes choices using text commands. In this problem and the next one, we’ll be developing a very simple text-based adventure game. Every choice in this game will have exactly three options, so we can write a function that works for any of them. Write a function selection(text, optionA, optionB, optionC), that takes in four string values. text is a string representing a prompt in a text adventure game, and optionA, optionB, and optionC are strings representing the three possible options. The function should print out the text, and then print out the options (label them with A., B., and C.). Next, the input() function should be used to prompt the user to choose A, B, or C. Then the function should return (not print) the one character string that represents the user’s choice: 'A', 'B', or 'C'. If the user does not choose one of those…good stat ofl them ii days. You need to upload your solutions in a single python file (assl.py) to the link on MS Teams. Part 1 Add this comment: # Ass 1: Part 1 Write a program that declares a function called draw Star which receives an integer value as a parameter, and draws a number of stars equal to the received integer. Samplel: Please enter the number of stars: 5 The shape is: **** Sample2: Please enter the number of stars: 3 The shape 15 *** Part 2 Add this comment: Ass 1: Part 2 Write a program that summation of even ni "nd M then prints the 3.9 nclud d if were even of 3Write a C++ prorgam with a function named getRandomMidpoint. This function should accept two arguments just like getMidpoint (getMidpoint. This function takes two int parameters, and returns the midpoint of the two integers. It has the following signature: int getMidpoint(int low, int high). But it should return a random number in between the low and high arguments. You can swap this function with the getMidpoint function to change the nature of how the program makes its guesses. Make sure to show output of your program using both getMidpoint and getRandomMidpoint showing different behaviors. Don't forget to add a call to srand() at the beginning of your program in main() to make sure each run of the program generates new "random" numbers.
- I am doing a word guessing game where I have created a function that shuffles a word randomly. However, I want to create a function that will act as a clue when the user presses it; it will display the first word of the jumbled word. For example, if the word is - friends, The Jumbled word would be - siedfrn, with the function I already made. However, in order for users to get some help, they can press a number(4), and the needed function will result in the output to be- fiedsrn.Write the convert_word code. convert_word is known as a function, which we will cover more in depth later. You are automatically given a parameter called word, which is a string that contains a single word. The return conv is how you will send data out of your function. The conv is a variable that hasn't been created yet, but it will be a string containing the converted hey. For example, if word="hey", then conv will be "heey". You are responsible for creating the variable conv, as the template has NOT done that for you. You need to use an if statement to see if the word starts with "he" and ends with "y". Since you don't know how many e's might be between the he and y, you have to do some math here. Recall that you can get the length of a string by using len(word) in the code above. You also know that h and y will be included. so, len(word) - 2 will be the number of e's in between the h and y. Create a string that contains the number of e's. This will be your conv variable. I would…The program will ask the user for their name and employee ID. The ID will be a five-digit number. This will be done in a single function, AskNameId, with bool return, where the name and id are passed as pointers. Read both variables as strings with a getline and convert the id to an int using atoi. Check that the id is not 0. If it is, cout a message to the user for entering an invalid id. Check if the name is an empty string. If it is, cout a message to the user for entering an invalid name. Return a bool, true if name and id are both valid and false if either one is not valid.