Write code that docs the following:
• Uses a lambda expression that accepts two int arguments, a and b, and returns the value of a * b.
• Assigns the lambda expression to a variable named multiply.
• Uses the multiply variable to call the lambda expression, passing the values 2 and 10 as arguments. The result should be assigned to an int variable named product.
Want to see the full answer?
Check out a sample textbook solutionChapter 17 Solutions
Starting Out with C++ from Control Structures to Objects (9th Edition)
Additional Engineering Textbook Solutions
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Starting Out with Programming Logic and Design (4th Edition)
Java: An Introduction to Problem Solving and Programming (7th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Starting Out with Java: Early Objects (6th Edition)
- JAVA:arrow_forwardFill-in-the-Blank When used as parameters, _________ variables allow a function to access the parameter’s original argument.arrow_forwardPlease do not give solution in image format thanku (C++) Create a Class called Pet and include the following attributes (3 string data types) Name PetType (this would be something like Dog, Cat, Bird, etc. ) Sound Constructors/Getters/Setters/Functions Constructor - 3 arguments - name, pet type, and sound Getters/Setters for all three attributes PrintPet method/function that will print the attributes such as: Name: FluffyType: CatSound: Meow Program User prompts: Name PetType (this would be something like Dog, Cat, Bird, etc. ) Sound Program requirements Main program to demonstrate the class. (Your main Method) Pet.h file (or hpp depending on your IDE) Pet.cpp file You will need to prompt the user for the Pet information to populate the Pet class attributes. Once you have the data - create a Pet and hand the variables to the 3 Argument Constructor. Output of the values of the attributes Pet instance as shown above Deliverables - Upload the following files in a zip folder that you…arrow_forward
- Instructions: In the code editor, you are provided with a treasureChestMagic() function which has the following description: Return type - void Name - treasureChestMagic Parameters - an address of an integer Description - updates the value of a certain integer randomly You do not have to worry about how the treasureChestMagic() function works. All you have to do is ask the user for an integer and then call the treasureChestMagic() function, passing the address of that integer you just asked. Finally, print the updated value of the integer inputted by the user. Please create a main code for my function that works with this. This is my code: #include<stdio.h>#include<math.h> void treasureChestMagic(int*); int main(void) { // TODO: Write your code here return 0;} void treasureChestMagic(int *n) { int temp = *n; int temp2 = temp; *n = *n + 5 - 5 * 5 / 5; temp2 = (int) pow(2, 3); if(temp % 3 == 0) { *n = temp * 10; } else if(temp %…arrow_forwardCode using java programming language.arrow_forwardFunctions With Parameters and No Return Values Quiz by CodeChum Admin Create a program that accepts an integer N, and pass it to the function generatePattern. generatePattern() function which has the following description: Return type - void Parameter - integer n This function prints a right triangular pattern of letter 'T' based on the value of n. The top of the triangle starts with 1 and increments by one down on the next line until the integer n. For each row of in printing the right triangle, print "T" for n times. In the main function, call the generatePattern() function. Input 1. One line containing an integer Output Enter·N:·4 T TT TTT TTTTarrow_forward
- C++ programming Chapter(s) Covered: Chapter 1-8 Concepts tested by the program: Working with one dimensional parallel arrays Use of functions Use of loops and conditional statements Project Description The Lo Shu Magic Square is a grid with 3 rows and 3 columnsshown below. The Lo Shu Magic Square has the following properties: The grid contains the numbers 1 – 9 exactly. Each number 1 – 9must not be used more than once. So, if you were to add up thenumbers used, The sum of each row, each column and each diagonal all add upto the same number, Write a program that simulates a magic square using 3 onedimensional parallel arrays of integer type. Each one the arrays corresponds to a row of the magicsquare. The program asks the user to enter the values of the magicsquare row by row and informs the user if the grid is a magicsquare or not. See the sample outputs for more clarification. Project Specifications Input for this project: Values of the grid (row by row) Output for this…arrow_forwardJava : Write a function, that generates a random password. It will return the randomly generated password as its ONLY result. Password Criteria:1. The password should have a random length of between 4 and 7 characters. 2. it may contain all letters Upper and lower casearrow_forwardTrue or false: When an object is passed to a function, but the function is not supposed to change it, it is best to pass it by value.arrow_forward
- Static Variable: a variable whose lifetime is the lifetime of the program (static int x;) Dynamic Variable: It is a pointer to a variable (int *x;) Is this comparison true?arrow_forwardneed help defining a function, dogBreeder, that accepts up to two optional arguments: name (string) age (number) dogBreeder should return an object that represents a new dog! If the user doesn't define a name, assume the dog's name is 'Steve'. If the user doesn't define the dog's age, assume the dog's age is 0. example dogBreeder('Sam', 12) // => {name: 'Sam', age: 12} dogBreeder(15) // => {name:'Steve', age: 15} dogBreeder('Sam') // => {name:'Sam', age: 0} dogBreeder() // => {name: 'Steve', age: 0}arrow_forwardText-based adventure game: Pretend you are creating a text-based adventure game. At different points in the game, you want the user to select to fight, run, or hide from certain enemies. Modify the application below (week3.py) so that the selection variable is sent as an argument into the choice() function. The user should enter 1 to fight, 2 to run, or 3 to hide in the main(). The choice() function should print one of the three options. You will need to add an if statement in the choice() function to make the correct selection.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education