Q2) The following graph shows the x and y coordination of different cities. Write a C Program that calculates the Euclidean distance, Minkowski distance and the difference of them between each pair of cities. Your program should have three functions; the first function calculates all requested distances. The second function finds the closest and furthest cities based on Euclidean distance and prints them. The third function prints the city numbers, the Euclidean distance between the cities, the Minkowski distance between the cities and the difference of distances in a tabular format.
Q: Write and test the “digit" function: Function Prototype: int digit(int n,int k) This function…
A: #include <iostream> using namespace std;int digit(int n ,int k){ int i=n; int x = n, c =…
Q: Q3 Write a program in C ++, with a row in the name (Shape), to calculate the total area of the…
A: Explanation: In the above question the shape is not defined and so i am providing a program which is…
Q: Design a function that accepts an integer argument and returns the sum of all the integers from 1up…
A: Algorithm Start int num Accept num from user sum=calculateSum(num) Print(sum) Stop. Function…
Q: Part 8: Take two points from user that defines a point location in 20 Cartesian co-ordinate. Write a…
A: I have given c++ code below
Q: 1) Define a struct to store fractions like a/b where a is numerator and b is denominator and a and b…
A: Program: #include<stdio.h> #include<stdlib.h> // DEFINING STRUCTURES struct add { int…
Q: Create a C function getPrime( ) with one argument type of integer your function checks the integer…
A: A number is said to be prime number if it has only two factors one and itself. For example 5 is a…
Q: Solution in JS Create a function that takes two numbers as arguments and return the LCM of the two…
A: The C++ code for given question ..
Q: Q1: Write a C++ program to create a header have a function that add two numbers. Then call the…
A: #include <iostream> #include <conio.h> using namespace std; int main() {…
Q: 6.use c code to Develop a code that gets two integers from the user and calculates and prints their…
A: PROGRAM INSTRUCTIONS: Let us consider a C program that gets two integers from the user and…
Q: 4.16 LAB: Toll calculation Toll roads have different fees based on the time of day and on…
A: Program Explanation:- If time is before 7. If the time is after 8 not in the morning. If the time…
Q: 5: Complete the function that takes in a number x, and returns the value 1 if x > 0, otherwise it is…
A: Logic:- within step_function use if else to check value of x is greater than or equal to 0 or not.…
Q: SUTASK the user to enter his height in centimeters and weight in grams. You are required to write a…
A: Step 1: Accept Name Step 2: Accept height in centimetres Step 3: Accept weight in grams Step 4:…
Q: Q1: Write a c++ program to create a header have a function that multiply two numbers. Then call the…
A: Note: we are only allowed to solve one question in one post. I am solving the first on here. To get…
Q: Write a value-returning function in c++, isVowel, that returns the value true if a given character…
A: Code : #include <iostream>using namespace std; bool isVowel (char c) {if (c == 'a' || c == 'e'…
Q: Question 4: Total Price Implement the function total_price , which takes in a list of prices of…
A: logic:- define function set total=0 iterate the list using for loop. Set tax=0 if i>=20…
Q: in C# Sometimes figuring letter grades is hard. Write a program that asks for, and reads from the…
A: C# program
Q: Hi A game is played in which a single dice is tossed. If the result is 4 or 6, the player wins. If…
A: Above function game re-written in switch-case statement: void game(int roll) { switch (roll)…
Q: a) Explain the operation of the lines commented as lines A -E b) What is the importance of the main…
A: A) Line A:- Declaring varible 'a' of data types 'double' (8 bytes) Line B:- While(1) is an infinite…
Q: Fill-in-the-Blank Either a function’s _________ or its _________ must precede all calls to the…
A: Either a function’s _________ or its _________ must precede all calls to the function.
Q: (Coin Tossing) Write a program that simulates coin tossing. For each toss of the coin theprogram…
A: (Coin Tossing) Write a program that simulates coin tossing. For each toss of the coin theprogram…
Q: B) R1= 20, R2-40 resistors are connected in series and R3-120, R4-40 resistors are connected in…
A: Here, we have given a Circuit Diagram , with 4 resistances R1 , R2 , R3 , R4 and Voltage V. We have…
Q: 8: PGandE.cpp) Consider a gas and electric bill that sets two levels of use as follows: Gas Electric…
A: Coded using C++.
Q: 1- Write C++ program (a Main function) that prints out whether a thrill-seeking person standing in…
A: Program Explanation:- Using the header file. Using the standard namespace input/output function.…
Q: 5: CheckLetter.cpp) Write a program that adds a check letter to an eight-digit number. The check…
A: Program description : The C++ program, CheckLetter.cpp ask user to enter the 8-digit number .Then…
Q: ++ the following function header is for a function that takes two pointers to double-precision,…
A: Explanation: The function header of the function void exchange(double *x, double y) takes two…
Q: Q15/ Write a program in c++ to display the message: "PROCEED" or "ABORT" depending on the input. If…
A: C++ is one of the most popular programming languages developed by Stroustrup at Bell Labs. The basic…
Q: 1. Write a function is divisible that takes two numbers and Nas inputa, and that returns True (the…
A: Python Program: # Takes two number m and n as user inputm = int(input("Enter the value of m: "))n =…
Q: (The function that returns letter grade according to midterm and final grade) : The function…
A: Required: The function turn_to_letter decides on the letter grade of the student according to the…
Q: velop a C program that computes the different roots in a quadratic equation, aX + bX2=0. r = -b…
A: Answers to both questions are given below.
Q: Write a code im c++ to overload area() function that can find the area of circle, rectangle ,…
A: Formula to calculate the area of the circle of radius, r: area=3.0×π×radius×radius Formula to…
Q: Q3 Write a program in C++, with a row in the name (Shape), to calculate the total area of the figure…
A: The area of right half circle is: (PI *( a * a)/ 4) The area of left half circle is: (PI *( b…
Q: Example 7, 8, 9 7. Continue example 5. Write a print function for sEmployee struct that will print…
A: Algorithm: Start Define a structure with id,name,title and salary as its members Inside main…
Q: Part II: Write a program to calculate the area of a triangle given the length of its three sides-a,…
A:
Q: (Time in Seconds) Write a function that takes the time as three integer arguments (forhours,…
A: Lets see the solution.
Q: Q1: Write a C++ program to create a header have a function that multiply two numbers. Then call the…
A: Open notepad and write multiply.h content written below. save it and store it in include folder.…
Q: The Worksheet named Grades contains a place for students to record the grades they have received in…
A: Sub showValue() Dim arr(9) For i = 0 To 8 Step 1 arr(i) = Range("B" & (i + 2)) Next…
Q: Q5) Write a C++ program to find the Fibonacci Series up to n number of terms. The Fibonacci sequence…
A: Write a C++ program to find the Fibonacci series up to n number of terms. The Fibonacci is a series…
Q: Activity 4: Write a C program to compute the area and circumference of a circle, take the radius as…
A: Solution: To find area and circumference of circle.
Q: 9. Write a function that receives marks received by a student in 7 subjects and returns the avera…
A: Program Approach: Include necessary header files to get the standard I/O. Define a function to…
Q: Question 3 Write a C program to compute the area and hypotenuse of a triangle using 3 functions. i)…
A: I hope it will help you #include<bits/stdc++.h>#include <iostream>#include…
Q: “Days Into Year (C++)” By using my code (photo is attached), implement a Days Into Year function.…
A: A date has to be taken from user in the required format. A function that returns how many days we…
Q: write a c++ function that counts the words in a string but does not include numbers for example…
A: #include <bits/stdc++.h>using namespace std;bool CheckNumber(string s){ for(int…
Q: 3. You are expected to write a recursive function called powy(base, exponent) that, when called,…
A: EXPLANATION: - The function powy(int base, int exponent) is defined with two parameters of integer…
Q: Q4, a mechanical pump whose rated speed is (Sm=15 cfm) is connected by a pipe and valve to a vacuum…
A: C++ program to find the amount of loss in process unloading is as given below.
Q: Fill-in-the-Blank A(n)_________ eliminates the need to place a function definition before all calls…
A: Given: Fill in blanks
Q: Q3: Write C++ program to calculate the sum of the following series and print the result from the…
A: I have provided code and output.
Q: 1. Write a C program which will calculate and display the net salary of an employee after tax and…
A: As per our guidelines we are supposed to answer only one question in case of multiple questions.…
Q: Exercise - Seconds since midnight 1 Let's write a program that reads the time from the user as three…
A: 12 o' clock here is assumed to be the midnight 12 o' clock (12:00 am). 1 minute contains 60 seconds.…
in C
Step by step
Solved in 5 steps with 1 images
- Python only* Use recursive function*. Define concentricCircles with 4 parameters Use def to define concentricCircles with 4 parameters here is the specification for concentricCircles function: It draws a series of concentric circles, where the first parameter specifies the radius of the outermost circle, and the second parameter specifies the number of circles to draw. When viewed as nested rings, all rings should have the same thickness. The third and fourth parameters specify an outer color and an other color, respectively. The outer color is used for the outermost circle, and then every other circle in to the center alternates between that color and the other color. We will test both how many circles are drawn as well as whether the correct circles are drawn in the correct order. Hint: Each function call frame only needs to draw a single circle. Note that you must use the turtleBeads drawDot function to draw each circle Do not use any kind of loop Within the definition of…Python only* Use recursive function*. Define concentricCircles with 4 parameters Use def to define concentricCircles with 4 parameters here is the specification for concentricCircles function: It draws a series of concentric circles, where the first parameter specifies the radius of the outermost circle, and the second parameter specifies the number of circles to draw. When viewed as nested rings, all rings should have the same thickness. The third and fourth parameters specify an outer color and an other color, respectively. The outer color is used for the outermost circle, and then every other circle in to the center alternates between that color and the other color. We will test both how many circles are drawn as well as whether the correct circles are drawn in the correct order. Hint: Each function call frame only needs to draw a single circle. Note that you must use the turtleBeads drawDot function to draw each circle Do not use any kind of loop Within the definition of…C Program: An integer number is said to be a perfect number if its factors, including 1 (but not the number itself), sum to the number. For example, 6 is a perfect number because 6 = 1 + 2 + 3. I have written a function called isPerfect (see below), that determines whether parameter passed to the function is a perfect number. Use this function in a C program that determines and prints all the perfect numbers between 1 and 1000. Print the factors of each perfect number to confirm that the number is indeed perfect. // isPerfect returns true if value is perfect integer, // i.e., if value is equal to sum of its factors int isPerfect(int value) { int factorSum = 1; // current sum of factors // loop through possible factor values for (int i = 2; i <= value / 2; ++i) { // if i is factor if (value % i == 0) { factorSum += i; // add to sum } } // return true if value is equal to sum of factors if (factorSum == value) { return…
- ***in python only*** use turtle function Define the concentricCircles function such that: It draws a series of concentric circles, where the first parameter specifies the radius of the outermost circle, and the second parameter specifies the number of circles to draw. The third and fourth parameters specify an outer color and an other color, respectively. The outer color is used for the largest (i.e., outermost) circle, and then every other circle out to the edge alternates between that color and the 'other' color. The difference between the radii of subsequent circles is always the same, and this difference is also equal to the radius of the smallest circle. Put another way: the distance between the inside and outside of each ring is the same. Define concentricCircles with 4 parameters Use def to define concentricCircles with 4 parameters Use any kind of loop Within the definition of concentricCircles with 4 parameters, use any kind of loop in at least one place. Call…[Fish Tank] You play with a clown fish that has an initial size so. The fish can eat other fish in a tank organized in m columns and n rows. The fish at column i and row j has a positive size si,j. When your fish eats another fish, it grows by that amount. For example, if your clown fish has a size of 10 and eats a fish of size 5, it becomes of size 15. You cannot eat a fish that is bigger than your size. The game starts by eating any fish in the first (left-most) column that is not bigger than yours. After that, you advance one column at a time by moving right. You have only three allowed moves. You either stay at the same row, move one row higher or one row lower. You will always move to the right. Thus, you will make exactly m moves to advance from left to right. Your goal is to exit the fish tank from the right with the biggest possible size. The figure below shows an example with the best answer highlighted. In this case, the final fish size is 71 (10+8+7+24+22). You are required…Trigonometry: The basic MATLAB trigonometric functions are sin, cos, tan, cot, sec, and csc. The inverses, e.g., arcsin, arctan, etc., are cal- culated with asin, atan, etc. The same is true for hyperbolic functions. The inverse function at an2 takes two arguments, y and x, and gives the four- quadrant inverse tangent. The argument of these functions must be in radians. Calculate the following quantities: sin, cost, and tan. sin²+ cos². (Typing sin^2(x) for sin²x will produce an error). y cosh²z-sinh² x, with x = 32m.
- This is c programming question. Use function please for solving. Question: (The function that returns letter grade according to midterm and final grade) : The function turn_to_letter decides on the letter grade of the student according to the table below from the visa and final grades sent into it and returns it, write it together with a main function which the turn_to_letter function is called and prints the letter equivalent on the screen. - Success score = 40% of midterm + 60% of final, - F for the success score below 50, D for between 50 and 59, C for between 60 and 69, B for between 70 and 79, A for 80 and above.C++ Toll roads have different fees at different times of the day and on weekends. Write a function CalcToll() that has three arguments: the current hour of time (int), whether the time is morning (bool), and whether the day is a weekend (bool). The function returns the correct toll fee (double), based on the chart below. Weekday Tolls Before 7:00 am ($1.15) 7:00 am to 9:59 am ($2.95) 10:00 am to 2:59 pm ($1.90) 3:00 pm to 7:59 pm ($3.95) Starting 8:00 pm ($1.40) Weekend Tolls Before 7:00 am ($1.05) 7:00 am to 7:59 pm ($2.15) Starting 8:00 pm ($1.10) Ex: The function calls below, with the given arguments, will return the following toll fees: CalcToll(8, true, false) returns 2.95CalcToll(1, false, false) returns 1.90CalcToll(3, false, true) returns 2.15CalcToll(5, true, true) returns 1.05 Your program should include the function main( ), which asks for and validates the proper user inputs to be passed to the CalcToll( ) function. The function main() also displays the toll fees based…function [P, A] = rect(L, W) P= 2 (L+ W); A =L*W; end Above function is defined to find perimeter and area of a rectangle. If a rectangle has length 10 mm and width 7 mm then the correct way to get perimeter and area of a given rectangle by executing this function is Select one: a. [A, B] = rect(10, 7) b. rect(7, 10) c. [A, B] = rect(7, 10) d. rect(10, 7)
- Programming Language :- C 7. A function is defined for a positive integer n as follows: 3n + 1, if n is odd f(n) = { n if n is even 2 We consider the repeated application of the function starting with a given integer n, as follows: f(n), f(f(n)), f(f(f(n))), It is conjectured that no matter which positive integer n you start from; this sequence eventually will reach to 1. If n = 13, the sequence will be 13, 40, 20, 10, 5, 16, 8, 4, 2, 1. Thus if you start from n = 13, you need to apply function 10 times to reach 1. Write a recursive function that takes n as an input number and returns how many times function f has to be applied repeatedly to reach 1.Program in C++ only: Mahesh is very good at his analytical skills so his teacher Ramanujan wants to test his skills so he gives him a condition let's consider a rectangular R table containing N rows and M columns. Rows are numbered 1 to N from top to bottom. Columns are calculated from 1 to M from left to right. Each element of R is a non-negative number. R is pronounced steadily if the total number of elements in the ith line is not less and then the total number of elements in the i-line (1) th for each i lapho is 2 Kanye N and the total element in the Nth line is less than or equal to M. Your job is to find the number of fixed tables of different sizes N x M modulo 1 000 000 000 000. Input: 1 11 Output: 2CodeW X bFor fun X C Solved x b Answer + x https://codeworko... CodeWorkout X265: Recursion Programmlng Exercise: GCD The greatest common divisor (GCD) for a pair of numbers is the largest positive integer that divides both numbers without remainder. For function GCD , write the missing base case condition and action. This function will compute the greatest common divisor of x and y.You can assume that x and y are both positive integers and that x > y. Greatest common divisor is computed as follows: = x and GCD(x, y) = GCD(y, x % y). Examples: GCD (6, 4) -> 2 Your An swer: 1 public int GCD(int x, int y) { if > { 2. > 3. } else { 4. return GCD(y, x % y); 9. { 7. 1:09 AM 50°F Clear 1V 1. 12/4/2021 甲