In C, write a function that gets two ints a and b. If a>b the function returns a^3 + b^2, and otherwise it returns a^2 + b^3. int square_cube (int a, int b); For example: square_cube (1,2) should return 1 + 8 = 9. square_cube (10, 3) should return 1000 + 9 = 1009. square_cube (2, -1) should return 8 + 1 = 9. square_cube (-2, -1) should return 4 - 1 = 3.
Q: Write a function rps in Python that returns the result of a game of "Rock, Paper, Scissors". The…
A: def rps(p1 , p2): if((p1=="S" and p2 == "P") or (p1 == "P" and p2 == "R") or (p1 == "R" and p2 ==…
Q: New York is 11 hours behind Bangkok. You will write a function nycHour (bkkHour: int) -> str that…
A: A 24-hour format time ca be converted to 12-hour format by subtracting 12 from 24-hour time when…
Q: Programming in C Lab#03 Write a function that has the following prototype: int Equalcols (int "A,…
A: #include <stdio.h>#include <stdlib.h>int solve(int * arr,int row, int col){ int sum =…
Q: ngineers often measure the ratio of two power measurements in decibels, or dB, which can be…
A: Declare variables required to hold the values for the power ratio expression. Declare the variables…
Q: Problem M6-2 : Write a complete program that uses a function prototyped as : void logN( double x,…
A: #include<iostream> #include<math.h> #include<cmath> //includes cmath for log…
Q: Engineers often measure the ratio of two power measurements in decibels, or dB, which can be…
A: Program: #include <iostream> #include <math.h> using namespace std; double…
Q: Program this on C .Write a function to convert temperature from Fahrenheit to Celsius named…
A: Here I have made a function that takes Fahrenheit as input and then uses the formula to convert it…
Q: Write a function grade2number that takes a student's letter grade (A, B, C, D, F) as a char and…
A: Solution :: Code in C++ Please see the screenshot below for better understanding…
Q: 13. Write a function slope (xl, yl, x2, y2) that returns the slope of the line through the points…
A: Algorithm: Start Define 2 methods, slope() and intercept which takes x1,y1,x2,y2 as arguments…
Q: Write a function that takes the line number as a parameter and prints a number triangle and pattern…
A: #include<stdio.h> void pattern(int n) // user define function to draw the…
Q: plement a function that checks if a number is within a given range. It should accept the range…
A: Bool data type is used to return true false . Use if else to check if value lies within range or…
Q: Engineers often measure the ratio of two power measurements in decibels, or dB, which can be…
A: PROGRAM: //Header file #include <iostream> #include <math.h> //Using namespace using…
Q: a) Write a function to simulate coin tossing, the function will use rand function that gives an…
A: Required:
Q: To convert between Celsius and Fahrenheit, the following formula is used, where C = Celsius…
A: In this program, you need to write function called toCelsius() which will convert Fahrenheit…
Q: We can assign a value to each character in a word based on their position in the alphabet (a = 1, b…
A: We can assign a value to each character in a word based on their position in the alphabet (a = 1, b…
Q: Problem 1 Implement a function that checks if a number is within a given range. It should accept the…
A: Note, as there is no programming language mentioned in the question, I am solving it using Python…
Q: Write a C program that sends an array of 20 elements to a function named "find" and finds the…
A: #include <stdio.h>//function find with array as parametervoid find(int a[]){ float…
Q: Write a C program that reserves flight tickets for 150 customers to Germany. Write a function…
A: #include<stdio.h>#include<stdlib.h>#include<time.h>#include<string.h>struct…
Q: A function called Grader that takes a numeric score and returns a letter grade. Grader has one…
A: #include <stdio.h>#include <ctype.h>#include <math.h> char Grader(int marks){…
Q: Write a C++ program that computes and returns: • the smallest positive integer (n) for which…
A: The instructions are provided by the programmer according to the requirement using the programming…
Q: Write a function that takes a number and returns the largest digit value in the number. For example,…
A: The python program is written where it takes the input from the user and prints the largest number.…
Q: Write a standard function definition that takes 1 parameter. The parameter is a number and the…
A: Here is the complete working code below function myFunction(num) { let sum = num; for(let i =…
Q: Suppose that you have the following function definition. int find(int x, int y){return (x + y - x *…
A: (a) The function call u = find (list1[0], v); is valid. Explanation: An integer arrays list1[0] and…
Q: Write a program c++ that prints a receipt with the following information. Let the program has the…
A: Step 1 : Start Step 2 : Define a Function printMenu() to print the Menu. Step 3 : In the main…
Q: a) Write a function to simulate coin tossing, the function will use rand function that gives an…
A: As per the given problem, we need to randomly generate numbers 0 and 1 and count the number of heads…
Q: Write a function "DivRemain" that will return both the dividend and the remainder from dividing two…
A: #include <iostream>using namespace std; int* DivRemain(int n1, int n2){ int* arr = new…
Q: Write a function days_in_month() that returns the number of days in a month. The function has the…
A: PROGRAM CODE: #include <stdio.h> // include…
Q: Write a function that accept limit as parameter and returns the sum of multiples of 3 or 5 between 0…
A: the code is an given below : function to return sum of multiples of 3 and 5 between 0 and limit. def…
Q: Write a function with the following header to format a positive integer with the specified width:…
A: Program approach:- Import a package to get the standard I/O. Define a class. Define the main…
Q: 2. Create a function that determines the length of the shortest ladder that reaches from the ground…
A: The MATLAB code is given below:
Q: Write a function NumberOfPennies() that returns the total number of pennies given a number of…
A: Program: #include <iostream>using namespace std;int NumberOfPennies(int NumberOfDollars, int…
Q: Write a C++ program that computes and returns: • the smallest positive integer (n) for which…
A: The program includes instructions for solving the problems and outputs the results. The program's…
Q: Write a C++ function named enough that takes one integer argument (goal), and returns as its value…
A: Here, Code instruction is given.
Q: A C program. Which circle has two data members, a Point representing the center of the circle.(using…
A: #include<stdio.h>#include<math.h> typedef struct{ float x; float y;}Point; typedef…
Q: Consider the following function that takes two positive integers x and y as its input parameters.…
A: First lets understand the recursive function:The function which calls itself directly/indirectly in…
Q: Create a function that takes in an integer n and returns the least commonly occurring non-zero…
A: Here I have first of all defined the function with an empty list. Now in the function, I have used…
Q: Define a C++ function hypotenuse that calculates the hypotenuse of a right triangle when the other…
A: Since you are not mentioning the programming language. We are using C++ to complete this program.…
Q: C++ ASAP plz First: Write a function to check whether a given number is a prime number. A prime…
A: Declare a variable number and read the value from the user. In the if statement, call the function…
Q: Write a Python function that meets the following requirements: Name the function degreeFormatter.…
A: Answer in step2
Q: Write a program BMI.py that performs the following, Define a function called getBMI that takes…
A: Question given - Define a function getBMI that calculate a person's BMI score based on person's…
Q: Write a program in c++ that defines four functions to round a number x in various ways: a)…
A: The required C++ code is given below: #include<iostream> #include<math.h>using namespace…
Q: Write a function definition that can compute the force of gravity between two given objects, where…
A: The given problem is related to programming language where the requirement is to implement a…
Q: Write a function future-date which takes four integer parameters: year, month, day and num-days. It…
A: You'd have to pick a reference year, say 1600, and then make the input invalid if the user enters a…
Q: Write a function tuplinator (number) that takes a number argument and returns a tuple consisting of…
A: ALGORITHM:- 1. Create an empty tuple. 2. Insert the received number, its square and its cube in the…
Q: Write a function to check if a given input number is a jumping number. A number is called jumping…
A: Since no programming language is mentioned, I am using python. Code: def checkJump(n): flag=1…
Q: Write a function is_valid_triangle(a,b,c) that gets three parameters that are the lengths of edges…
A: The problem is based on finding the validity of a triangle whose sides are given using python…
Q: In Python: Write a function called is_prime that receives a single integer value between 1 and 50…
A: def is_prime(n): if(n==1): print(n,"is not prime") exit() else: s = 0 #…
Q: Write a function that accepts an integer as it's only argument. The function calculates and returns…
A: The required function in python is : def Func1(t): s=0…
Q: Write a function GCD( int A, int B ), when called from main function, returns the GCD (Greatest…
A: Note: As the language is not specified answer written in c++
Q: Write a main function that asks the user to choose whether to find the area of a rectangle, the…
A: Program plan: Define a function rectangle_area(length, width) which calculates the area of the…
In C, write a function that gets two ints a and b. If a>b the function returns a^3 + b^2, and otherwise it returns a^2 + b^3.
int square_cube (int a, int b);
For example:
- square_cube (1,2) should return 1 + 8 = 9.
- square_cube (10, 3) should return 1000 + 9 = 1009.
- square_cube (2, -1) should return 8 + 1 = 9.
- square_cube (-2, -1) should return 4 - 1 = 3.
Step by step
Solved in 2 steps
- Program this on C .Write a function to convert temperature from Fahrenheit to Celsius named “ConvertFtoC” that takes one double value for Fahrenheit as argument, and returns the equivalent temperature in Celsius(type double). Create a program that exercise this function by obtaining a Fahrenheit value from the user, calling the function, and displaying the value of Celsius it returns. [Formula: Celsius = (Fahrenheit – 32 ) * 5/9 ]Write a program c++ that prints a receipt with the following information. Let the program has the following function 1. Ask the user to write the first and last name. 2. function which contains the following list and allows the user to choose at least 2 items, each item has a price a. Lemon Juice3$ b. Cola 7$ c. ice tea 4$ d. Chips 5$ e. Chocolate 6$ f. Ice Cream $9 3. Fine total price for items that the user chose 4. Find the largest price the user purchase 5. Print the receipt in following order last name... List of requested items: Total price:----- The average of your order is: The largest item you purchase is:Write a program in c++ that calculates the area and perimeter of an upright rectangle.Create a struct Point that has two double values, x and y. Write a function that asks the user for a Point. Call that function twice, once to get the bottom left corner of a rectangle, and once to get the top right corner. Write another function that takes two Points and returns area and perimeter. Print out the area and perimeter. Given two points (x1,y1) and (x2,y2), the formulas to compute perimeter and area are as follows P erimeter = 2 ∗ (abs(x1 − x2) + abs(y1 − y2))Area = abs(x1 − x2) ∗ abs(y1 − y2)
- Write a function rps in Python that returns the result of a game of "Rock,Paper, Scissors". The function accepts two arguments, each one of 'R','P','S' , that represents the symbol played by each of the two players. The function returns: -1 if the first player wins0 if a tie1 if the second player winsScissors beats Paper beats Rock beats Scissors Sample usage: >>> rps('R','P') # player 2 wins, return 11Python Help Write a function rectangle_area(length, width)Write a function rectangle_perimeter(length, width)Write a function circle_area(radius)Write a function circle_circumference(radius)Write a main function that asks the user to choose whether to find the area of a rectangle, the perimeter of a rectangle, the area of a circle or the circumference of a circle. If the user chooses to find the area of a circle use circle_area function, if the user chooses to find the area of a rectangle use rectangle_area function and so on.Write a function for the Superman ride at Six Flags that determines whether the user is taller than 4'8" so that he or she can ride a roller coaster
- In C++ just do the problems in simple, not complicated code. Even if a problem does not directly tell you to use a function, you should aim to do so regardless. 1. Create a function that takes in a number n and outputs all the odd numbers from 1 to n. 2. Create a function that takes in a int number and outputs each of the digits backwards 3. Create a function that counts backwards from 100 to 1. 4. If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.Find the sum of all the multiples of 3 or 5 below 1000. Use a function to do this. Return the total to main.PYTHON!!! Write a function that receives 3 assignment grades, a1, a2, a3, and a final grade, f, for a student and returns the corresponding letter grade of the student. The weights for the assignments and the final are 0.2, 0.2, 0.2, and 0.4, respectively. You can use the following table for matching grades to letters: 95-100 -> A1 90-94 -> A2 85-89 -> A3 80-84 -> B1 75-79 -> B2 70-74 -> B3 65-69 -> C1 60-64 -> C2 55-59 -> C3 40-54 -> D 0-39 -> F For example, compute_letter(80, 60, 40, 70) returns "C2" because 80 * 0.2 + 50 * 0.2 + 40 * 0.2 + 70 * 0.4 = 62 and 62 corresponds to C2. Note that, you are expected to do rounding. For example, 39.4 is F, whereas 39.5 is D. You can use the builtin round() function for this. Please google this function and learn how to use it. """ def compute_letter(a1, a2, a3, f):Write a c++ program: Write a function named convertToLowestTerms that inputs two integer parameters by reference named numerator and denominator. The function should treat these variables as a fraction and reduce them to lowest terms. For example, if numerator is 20 and denominator is 60, then the function should change the variables to 1 and 3, respectively. This will require finding the greatest common divisor for the numerator and denominator then dividing both variables by that number. If the denominator is zero, the function should return false, otherwise the function should return true. Write a driver program that uses convertToLowestTerms to reduce and output several fractions.
- Engineers often measure the ratio of two power measurements in decibels, or dB, which can be calculated as follows:dB= log10P2/P1Where P2 is the power level being measured, and P1 is some reference power level. Write a function that calculates the level. The function’s prototype is as follows:double dBCalculator (double P1, double P2);Then, call dBCalculator from the main function to find the power ratio for the measurements from 1 to 20 Watts, in 2 Watt steps. You can assume that the reference power P1 is 1 Watt.Write program in C; compatible with quincy please Write a program that calculates the area (a) of a triangle given two values b (base) and h (height) and using the formula area = (base * height) / 2 .The program should include a function called calculate_area which has two input parameters(b and h) and one output parameter (a).The user is prompted to enter two input values that will be used as base (b) and height (h) thenthe function calculate_area uses those two values as input parameters returns the calculatedarea (a) as an output parameter. After using the function calculate_area the program shoulddisplay the calculated area (a).Hint: use a pointer for the output parameterWrite a C program that reserves flight tickets for 150 customers to Germany. Write afunction RegCust that for each customer gets name, surname, Passport ID, and age. If the age ofthe customer is less than 18 years old, the customer is not allowed to buy a ticket and the programmust show a warning message to the user. Write another function ResTCKT that reserves thetickets by saving the Passport ID and seat number for the customers. Seat numbers must beassigned randomly between 1 and 150 with no repeating random number. Write a third functionPrintTCKT that shows the complete name of customers and their seat number as tabular formatshown below. You need to use array of structures and pointers for implementation of thisprogram.Struct Customer{char *name;char *surname;int passID;int age;} Custs[150]; Struct Ticket{int passID;int seatNum;} TCKT[150];