Q2: Answer two of the following: 1- Write a C++ function that returns the sign of the number. The function should work with integer and float numbers. C++ (-1 ifx<0, sign(x) ={ 0 if x = 0, 1 if x>0. 2- Write a C++ program to ask the user to enter his her first and second name. After that, ask them to enter their third name and then save the first, second and third names in a new string.
Q: Write C++ function that returns the largest value of five value. Call the function in your main…
A: Ans: Code: #include <iostream>using namespace std; int main() { int i, n = 5; int arr[n];…
Q: 2- (What's the Value of X?) The following program uses function multiple to determine if the integer…
A: Sample outputs:
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: Write a python function that takes a number as a parameter and returns true if the number entered by…
A: def isINT(n): # user define function to check a number is integer or not…
Q: Write a C99 function that includes the following sequence of statements: x = 21; int x; x = 42;
A: Solution
Q: Q7: The Fibonacci Series is: 0, 1, 1, 2, 3. 5, 8, 13, 21, ... It begins with the terms 0 and land…
A: function: int fibonacci(int x){ //condition to validate the values if((x==1)||(x==0)) {…
Q: Use C++ coding A “Perfect” number is a positive whole number that is the sum of its proper divisors…
A: #include<iostream>using namespace std;int main(){ int n; cin>>n; int sum=1;…
Q: Write a C++ program that prompts the user to enter two integer numbers and the program should print…
A: Algorithm : - we will convert the inputed number to string - we will store the index of largest…
Q: iii) Write a C program to find the value of x after taking the value of y. Where x,y are two…
A: Step-1: Start Step-2: Declare a integer variable y and x Step-3: Take input from user for y Step-4:…
Q: 3. Using functions, develop a full C++ structured program that asks the user for his choics:1 or 2.…
A: Functions required:- convertToF() convertToC() Formula used f=(9/5)*c +32 Formula used…
Q: 1. Write a C program to input any number from user and find cube, square and square root of the…
A: The program prints Cube, Square and Square Root of the given number. It uses math.h library for…
Q: can someone help me with this in C++ A character value (a letter from the English alphabet) A…
A: - We need to highlight the code for character match in a string.
Q: a. Declare variables to store three sides of a triangle. The variable should be able to be accessed…
A: #include <stdio.h>#include<math.h> float AreaOfTraingle(float,float,float);…
Q: A temperature reading in degrees Fahrenheit can be converted to degrees Celsius using Write a…
A: #include <stdio.h>float convertCelFahrenheit(float f){ return ((f-32)*5)/9;}int main(){…
Q: Write program to find the factorial of number less tham 15. Write complete code in main function,…
A: To determine the factorial, all integers are a multiplication of n. For loop allow the user to input…
Q: Write a C++ program that promote the user to enter two numbers and an operation sign (+ or * or - or…
A: In programming, a function is a block of code used to perform certain actions, which is executed…
Q: The distance between two points pA (XA,YA) and pB (XB,YB) is calculated as follows V(XA-XB)+(YA–YB)…
A: Find the required code in C++ given as below and sample output :
Q: c programming - solve with function please Code The function named "odd_ even" to find out whether…
A: Below is the detailed and simplified C code for the above listed problem statement:
Q: Hello everyone. I have homework and I do but code is complicated for me. Homework. This program…
A: According to the question below the solution: Output:
Q: Write a function that prints your name as the last two digits of your number (with a Do-While loop).…
A: To take the input of whole name fgets function is used. fegts function takes input irrespecive of…
Q: Write a C++ code that calculates the value of f(x) depending on the value of x as follow (use…
A: C++ is one of the most popular programming languages developed by Stroustrup at Bell Labs. The basic…
Q: • High and Low Write a program that determine which number is higher between two integers. Get the…
A: The Answer is
Q: DO IT WITH C++ PROGRAM 1. Write a parameter and return program that will require the user to enter…
A:
Q: 3- write a program C++ that accepts a character as input and determines whether the character is a…
A: Answer: #include<iostream>#include<conio.h>using namespace std;int main (){ char c;…
Q: 2.use c code to Write a function that gets a string as a parameter and reports (prints out) the…
A: PROGRAM: //include the required header files #include <stdio.h> #include <string.h>…
Q: Write the code to define the abs() function in the C language. The function should take an integer…
A: Write the code to define the abs() function in the C language. The function should take an integer…
Q: 3. Using functions, develop a full C++ structured program that asks the user for his choics:1 or 2.…
A: The given problem is to be solved in C++ language where the conversion of the temprature will be…
Q: Write a complete C program to calculate the perimeter and area of a triangle with 3 sides namely a,…
A: PROGRAM: //Header files #include <stdio.h> #include <string.h> #include <math.h>…
Q: Q2: Using switch case, write C code for a program that reads two integer numbers A and B, and one…
A:
Q: 2. Which statement(s) is/are true regarding the round() function in C++? The round() function always…
A: Let us see the answer below,
Q: Write a C++ program that prompts the user to enter two integer numbers and the program should print…
A: The [program is implemented in C++ with procedural approach. Following is the program algorithm Ask…
Q: Type a function that mimics (without using >>) the right shift operator and returns the result from…
A: Code - const shiftToRight = (x, y) => { const formula = x / 2 ** y; return formula < 0 ?…
Q: Write a C++ code that calculates the value of f(x) depending on the value of x as follow (use…
A: C++ is one of the most popular programming languages developed by Stroustrup at Bell Labs. The basic…
Q: My homework This program reads a number of up to 9 digits. It then prints the number in English.…
A: C++ program to convert the given number to English word is given below.
Q: What does the following function do? float hypot(float x, float y) { return sqrt(x*x+y*y); }//end of…
A: Given that: Find the result of the given function: float hypot(float x, float y) { return…
Q: Write a C++ program that prompts the user to enter two integer numbers and the program should print…
A: The code and the output has been given in step 2.
Q: The Problem: Topics: Switch statement, Loops, Functions, Creating Program-Defined Value-Returning…
A: SUMMARY: - hence we discussed all the points.
Q: A C that deletes the desired character in a text that the user has entered on the keyboard write the…
A: Read a text string from the user and deleting a character. Pass the two arguments to the function.…
Q: 23. Write a C++ statement to call the functions given below with the parameters given along with…
A: #include<iostream>using namespace std;int funcA(int a,int b){ return a+b;}int funcB(int…
Q: The spring force, Fs of a deformed spring is defined as follows: Fs = K|L2 - L1| where K is the…
A: fabs function is used to find the positive difference of 2 float numbers
Q: Question 2) Program a function named isprime() by C program that inputs an integer number and…
A: #include <iostream>using namespace std;bool isPrime(int num); int main(){ int num; bool…
Q: Write a function that receives 5 integers and returns the sum, average and standard deviation of…
A: EXPLANATION - Take 5 number from user as input . Pass number as parameter in func and call func . In…
Q: Using c++ Write a program , that finds solution (roots) of quadratic equation, allow user to input…
A: Program This program is to find the roots of a quadratic equation. //Include necessary header files…
Q: Write a complete C program to calculate the perimeter and area of a triangle with 3 sides namely a,…
A: The following C code has five functions. They are: void menu() - This function is to print the…
Q: ii) Write a C++ function to take three numbers as parameters and return the largest number among the…
A: According to the Question below the Solution: Output:
Q: This program reads a number of up to 9 digits. It then prints the number in English. In other…
A: C++ program to convert the given number to English word is given below.
Q: Please use C++. Write the following function declarations as they would appear on single lines above…
A: Function declarations in C++ a. bool doTheLogic(bool a) b. bool doTheLogic(bool a, bool b) c. bool…
Q: Revise this C language program below by converting the power() function to with arguments passed and…
A: Use void return type with int Use scanf for accepting input from user
Step by step
Solved in 3 steps with 4 images
- c programming - solve with function please Code The function named "odd_ even" to find out whether the integer sent into it is odd or even and prints to the screen.(Electrical eng.) a. The voltage gain of an amplifier is given by this formula: voltagegain=[275 23 2 +0.5 f 2 ]n f is the frequency in Hz. n is the number of stages in the amplifier. Using this formula, write, compile, and run a C++ program to determine the value of the voltage gain for a four-stage amplifier operating at a frequency of 120 Hz. Your program should produce the following display: At a frequency of xxxxx hertz, the voltage gain is yyyyy Your program should replace xxxxx with the frequency and yyyyy with the voltage gain. b. Manually check the value your program produces. After verifying that your program is working correctly, modify it to determine the voltage gain of a 12-stage amplifier operating at a frequency of 9500 Hz.Numerical analysis) Given a number, n, and an approximation for its square root, a closer approximation of the actual square root can be found by using this formula: newapproximation=(n/previousapproximation)+previousapproximation2 Using this information, write a C++ program that prompts the user for a number and an initial guess at its square root. Using this input data, your program should calculate an approximation of the square root that’s accurate to 0.00001. (Hint: Stop the loop when the difference between the two approximations is less than 0.00001.)
- Mark the following statements as true or false: a. To use a predefined function in a program, you need to know only the name of the function and how to use it. (1) b. A value-returning function returns only one value. (2, 3) c. Parameters allow you to use different values each time the function is called. (2, 7, 9) d. When a return statement executes in a user-defined function, the function immediately exits. (3, 4) e. A value-returning function returns only integer values. (4) f. A variable name cannot be passed to a value parameter. (3, 6) g. If a C++ function does not use parameters, parentheses around the empty parameter list are still required. (2, 3, 6) h. In C + + , the names of the corresponding formal and actual parameters must be the same. (3, 4, 6) i. A function that changes the value of a reference parameter also changes the value of the actual parameter. (7) j. Whenever the value of a reference parameter changes, the value of the actual parameter changes. (7) k. In C++, function definitions can be nested; that is, the definition of one function can be enclosed in the body of another function. (9) l. Using global variables in a program is a better programming style than using local variables, because extra variables can be avoided. (10) m. In a program, global constants are as dangerous as global variables. (10) n. The memory for a static variable remains allocated between function calls. (11)(Hydraulics) a. Write, compile, and run a C++ program to calculate the horizontal force exerted on the T-connector pipe shown in Figure 2.16 when the mass flow rate is 1.5 kg/s, and the fluid’s velocity entering the T-connector is 3 m/s. The formula for determining this force is as follows: Fh=MfvFhisthehorizontalforce(N).Mfisthemassflowrate( kg/s).visthevelocity( m/s)ofthefluidenteringthepipe. Your program should produce the following display (replacing the xxxx with the actual force value your program calculates): The horizontal force, in Newtons, is xxxx b. Manually check the values computed by your program. After verifying that your program is working correctly, modify it to calculate the force exerted when the mass flow rate is 2.3 kg/s, and the velocity of the fluid entering the pipe is 4.25 m/s.Q1: Write a C++ program to read any integer number and determine if the number is not prime using function int prime(), the answer will be printed from the main function.
- DO IT WITH C++ PROGRAM 1. Write a parameter and return program that will require the user to enter a temperature in Celsius and convert it to degree Fahrenheit and degree Formula: Fahrenheit = (9/5) * Celsius + 32 Kelvin = Celsius + 273 2. Refer to No. 1, transform the program using function header and function 3. Write a global and local variable program that would require the user to input a value of the Radius of a circle and then show the output in the diameter, circumference of the circle and area of the circle.Hi I need help please I am resubmitting this question because I forgot to mention that It is in C++ language and I want to make a function which will find and replace parts of a string entered by the user and replace that substring with another string chosen by the user. I need help tutoring me on what variables and loops to use for this program pleaseAnswer the following. The correct one in function if the code.
- Write a C function to calculate the factorial of a number. Write the main() program to accept 10 numbers from the user and display the factorial for each number .Write a complete C program to calculate the perimeter and area of a triangle with 3 sides namely a, b, and c. The sides will be given as inputs by the user. The program will be executed at least once, and repeat as long as user wish to calculate again. There are a total of 5 functions: • Function 1: - This function will display the menu options that the user can choose (to calculate perimeter or area of a triangle). • Function 2: - This function will calculate the perimeter of a triangle - Accepts the sides of triangle as parameter - Formula: perimeter = a + b + c - Return the result back to the caller. • Function 3: - This function will calculate the area of a triangle - Accepts the sides of triangle as parameter - Formula: area = Vs (s — a)(s — b)(s — c), where s = (a + b + c)/2 - Return the result back to the caller. • Function 4: - This function will get the sides of triangle from user. - Ask user for option on what s/he would like to calculate. - Based on the option (Use switch…Q. Write a function days_in_month() that returns the number of days in a month. The function has the following prototype: int days_in_month(int month, int is_leap); Month should be an integer value between 1 and 12. The function should return (-1) if an invalid month is input. The variable ‘is_leap’ is 1 for leap years, 0 otherwise. Write program in c.