3. Write a program that calculates exp(x) using the Taylor series approximation exp_approx = 1 + x + x^2 / 2! + x^3 / 3! + .. where x and error are input from the keyboard and a sufficient number of series terms are used such that abs( exp_approx - exp(x) ) < error. Hint: Use *= in a loop to calculate x^i and i! and print them out to the screen to verify that your loop is correct before calculating the series approximation.
Q: c) From the given this sub_ program find the value of z: int x = 5, y = 5, z; X = ++x; y = - -y; Z =…
A: As per our guidelines we are suppose to answer only first question. Kindly repost other question…
Q: Machine Problem 3. Write a computer program that will implement Bairstow's method for solving roots…
A:
Q: Write a program computing terms of the sequence given by the condition: x_0=1, x_1=1/3,…
A: Here is the complete matlab code. See below step
Q: Write a program that asks the user to enter a non-negative integer value representing x. Declare a…
A: I have provided C++ CODE along with CODE SCREENSHOT and OUTPUT…
Q: 2. Write a python program to accept the CGPA, English score and age of 7 students using while loop.…
A: i = 1 #for counting how many student data enteredwhile i <= 7:…
Q: Write a program to find the sum cf the following series starting from X: S = X+ X-1 + X-2 + ... + 1…
A: As no programming language is mentioned, it is solved using basic C++
Q: Q1/Write program to find the value e^xof from the following series :- e* = 1 + ²/ 2! + + 4! 6! + +…
A: PROGRAM INTRODUCTION: Include the required header files. Start the definition of the function to…
Q: (a) Convert the following C++ code from while-loop to for-loop, such that it gives the same output.…
A: Below is the converted C++ code: - Explanation: - Importing the header file and the namespace.…
Q: Write a C ++ that uses while loops to perform the following steps: Prompt the user to input two…
A: A CPP programe for display all odd numbers and sum of all even numbers between 2 integers ( must…
Q: 2. Assuming a sequence of integer numbers, from X to Y (both received as input), where X<Y, write…
A: Given :
Q: Q3 Write a C++ program to evaluate the function Z for the following series using for loop (choose…
A: C++ "while" loop: Loop is used to repeat a set of statements until the loop condition is true. The…
Q: Problem 2: Postman Harry Harry is a postman. He's got a post office with a size of n rows office…
A: Define header files <iostream> for operations on input and output, <cstring> for playing…
Q: Write an assembly program that works on the following string in data segment. msg db "I 1m in…
A: DATA SEGMENT STR1 DB " ENTER YOUR STRING HERE - > $ " STR2 DB " YOUR STRING IS - > $" STR3 DB…
Q: Given num_rows and num_cols, print a list of all seats in a theater. Rows are numbered, columns…
A: Given :- Given num_rows and num_cols, print a list of all seats in a theater. Rows are numbered,…
Q: Note: it python code Try to convert for to while as one of the requirements is to do with while…
A: Hi. Let's move on to the code in the next step. I have included comments in the code wherever I…
Q: C++ question Conversion from kilograms to pound for odd numbers (1-99). Your output should list all…
A: Task :- Write a C++ program for conversion from Kilograms to Pound. C++ Program :- #include…
Q: Q3/A) Write a Matlb program to solve the following equation (find z value): 10 Σ z = y + (x² + y) dx…
A: Code: syms y f=@(x,y)(x.*x+y) z=symsum(y,1,10)+integral2(f,0,pi,0,2*pi) Note: symsum() is used…
Q: Write a program that takes in a line of text as input, and outputs that line of text in reverse. You…
A: Given: Write a program that takes in a line of text as input, and outputs that line of text in…
Q: Write a program to calculate and display sum of the following series using for loop x+x2+x3+………xn
A: Code: Output:
Q: Perform the following using DEV-C++ Show your solution Write a program that determines a student’s…
A: The given requirement has been implemented in C++ .
Q: Q3 Write a C++ program to evaluate the function Z for the following series using for loop (choose…
A: #include <iostream>#include <math.h>using namespace std; int Z(int x) { double sum =…
Q: tal amount the user needs to pay according to the given conditions: The user has to pay…
A: add <- function(x, y) {return(x + y)}subtract <- function(x, y) {return(x - y)}multiply <-…
Q: Consider a python function which returns True if an input integer is larger than 2 and also less…
A: Black box testing is a method to check functionalities of an application/software/program without…
Q: If x_0=5 and x_n=3x_(n-1) mod 150 a) Write a function R to generate 1000 pseudo random numbers based…
A: Pseudo-Random Number Generator: A pseudo-Random Number generator is refer to an algorithm that…
Q: The geometric mean of a set of positive numbers x, through x, is defined as the nth root of the…
A: Given The geometric mean of n numbers is, GM = n√x1.x2.x3....xn The…
Q: 2. Write a Python Program to Count all letters, digits, and special symbols from a given string Use…
A: Algorithm 0. Take user input for the string and store in str 1.For each character in the given…
Q: Write a Python program that computes the following mathematical function: a. computePI(terms) to…
A: The following are steps needs to be taken for the given program: We define a function named…
Q: Define function print_popcorn_time() with parameter bag_ounces. If bag_ounces is less than 3, print…
A: According to the Question below the Solution: Output:
Q: HW Due Monday 22/3/2021 (11:59 PM) Sin(x) can be expressed by Taylor series as below sin(x) = 00…
A: Fortran(F90) is a computer programming language that is extensively used in numerical, scientific…
Q: Q9: Write a program to find the partial sum for each of the following series: x x" x? x а.) х+. 2!…
A: a)Program:#include <iostream>#include <cmath>using namespace std;int main(){int…
Q: d) Given the following function in C, what is the output of each line? void func_p() { int nw = 123;…
A: PROGRAM EXPLANATION: Include the header file. Define the function as given in the question. Print…
Q: Write a Matlab script "pyramide.m" that asks for a number N and prints out the following pattern of…
A: Start Accept number of asterisks characters Run for loop runs for all rows. Run two for loops 1 loop…
Q: Write a program that defines n to be a random positive integer between 1 and 100 (use randi). If n…
A: n = randi(100)s = 0;if(mod (n,2) == 0) for num = 1:n if(mod(num,2)==0) s =…
Q: Write a code which enables a user to input the coefficients of a quadratic q(x) = ax² + bx + c and…
A: Required: Write a code which enables a user to input the coefficients of a quadratic q(x) = ax2 + bx…
Q: consider this data sequence: "3 11 5 5 5 2 4 6 6 7 3 -8". Any value that is the same as the…
A: code : - li = [3, 11, 5 ,5, 5 ,2, 4, 6, 6, 7, 3, -8] pre = None count = 0 # loop over each element…
Q: ) The script below demonstrates a very basic loop structure. Indicate the value of R1 after 5…
A: It is defined as a structure allows to execute a statement or group of statements multiple times.…
Q: Write a function which output all the prime numbers between 2 and a given positive integer 'n'.
A: NOTE : Since programming language is not mentioned. Therefore answering question in Python Language.…
Q: Make program that uses a while-loop to read only five float values from userInput. Ask the user to…
A: Find Your Code Below #include <stdio.h> int main(){ int count=0; float…
Q: Write a program to calculate the K value using if else condition If P value is more than 9 then K =…
A: Note: Answering the given question in python as no programming language is mentioned Input to the…
Q: (F, Consider a problem that requests the largest area of three triangles to be printed using MATLAB…
A: Ans::) In this MATLAB program, I am using the three triangles and vectors to store the values of…
Q: Write a code which enables a user to input the coefficients of a quadratic q(x) = ax² + bx + c and…
A: Matlab code: prompt = " Enter coefficient 'a' of quadratic equation"; a = input (prompt); prompt2 =…
Q: Dr@w the me@ly m@chine of @dder and u$e for following input. (b) 3*5+8, (c) 2+5+8+9, (d) 8*20+4*5
A:
Q: (a) Analyse the following code segment. int i=1,x =0; while (iy) x=y; i=i+1; System.out.println(x);…
A: a) i y while(i<4) x>y x 1 8 1<4 True 0>8 F 0 2 -5 2<4 True 0>-5 T -5 3 -1…
Q: Write a python program using while loop to find the sum of the below given series up to n. S = 5/10…
A: The given problem is a programming problem to be solved in Python language where the user will be…
Q: Task 8 1 Write a python program that splits a given string on a given split character. The first…
A: Program Approach: Take input from user. Create an empty list Loop through the string and find for…
Q: string of variables) except in statement '1'; on input a' replace X with y y can be {go. 91. 92).…
A: The answer for the language accepted by PDA is
Q: Give the output of the following program segments. int x- 10; do X-x+ 6; System.out printin(x);…
A: The Question requires to Provide the Output Generated for the Given segment of Program Code : Given…
Q: 9. Use loop to calculate the summations of the following series for given values of x and (i) 4 –…
A: 9. Write a program that will find the value of following series: (i) 4 - 4/3 + 4/5 - 4/7 .... nth…
Q: Implement the numerical approximation of √√2 using for loop, (conforming to 12 dec places). 2 X₁ = 1…
A: Given:
Step by step
Solved in 4 steps with 2 images
- Perform the following using DEV-C++ Show your solution Write a program that determines a student’s grade. It reads four test scores (between0 and 100) and calculates the grade based on the following rules: If the average score is 90 or more, the grade is ‘A’. If the average score is between 80 and 90, the grade is ‘B’. If the average score is between 70 and 80, the grade is ‘C’. If the average score is between 60 and 70, the grade is ‘D’. If the average score is less than 60, the grade is ‘F’.Write a simple nested loop example that sums the even and odd numbers between 5 and 15 and prints out the computation. Write a for loop with a range function for even numbers. Write a for loop with a range function for odd numbers. Use a variable called calc to calculate the sum of even and odd numbers. Print the computation of each even number plus the odd number equal to calc to the terminal.Write program that uses nested for loops to collect data andcalculate the total and average rainfall over a period of years. Theaverage will be a result of integer division so, it will not be preciselyaccurate but good enough.First the program should ask for the number of years. Use the readcommand for all user input. The outer loop will iterate once for eachyear. The inner loop will iterate 12 times, once for each month. Eachiteration of the inner loop will ask the user for the inches of rainfall forthat month. Use the read command for all user input. After alliterations, the program should display the number of years, the totalnumber of months, the total inches of rainfall, and the average rainfallper month for the entire period. Sample run:rainfall.shEnter the number of years: 1For year 1:Enter the rainfall for month 1: 2Enter the rainfall for month 2: 3Enter the rainfall for month 3: 2Enter the rainfall for month 4: 4Enter the rainfall for month 5: 2Enter the rainfall for month 6:…
- Write a for loop with a range function for even numbers. Write a for loop with a range function for odd numbers. Use a variable called calc to calculate the sum of even and odd numbers. Print the computation of each even number plus the odd number equal to calc to the terminal.Use PythonWrite a function, print_perfect_cubes(n), that takes an integer parameter n and prints the perfect cubes starting from 03 = 0 and ending with n3. When n is negative, the function prints nothing; but do not check for this condition with an "if" statement, it is unneccesary; use a for loop that will automatically print nothing when n < 0. Hint for choosing the right range for your for loop: In the general case, when n is not negative, your function will need to print n+1 different values. For example: Test Result print_perfect_cubes(2) 0 1 8 print_perfect_cubes(5) 0 1 8 27 64 125 print_perfect_cubes(-10)Modify the below program that the input values representingfractions are stored with denominators that are positive integers. You cannot require the user to only enter a positive denominator value; the user should not be inconvenienced by such a restriction. For example, whilst values of 1 / -2 are acceptable inputs for a fraction, the output representation should be -1 / 2. Your solution should check the denominator input; if it is negative, swap the sign of both numerator and denominator instance variables. //Import the essential package import java.util.ArrayList; import java.util.Scanner; //Define the class Fraction class Fraction { private int n, d; public Fraction() { //Initialize the values this.n = this.d = 0; } public Fraction(int n, int d) { //Initialize the variables this.n = n; this.d = d; } //Define the getter function getNum() that returns the numerator public int getNum() {…
- 3. Write a program that accepts two input numbers and compute the Greatest Common Divisor using do-while To get the GCD of another input number, type Y or y; otherwise, type N or n to quit the program. Sample Output: Enter the value of the first number: 10 Enter the value of the second number: The Greatest Common Divisor of 10 and 6 is 2 Type Y/y if you want to try again. Type N/n to exit. :This program outputs a downwards facing arrow composed of a rectangle and a right triangle. The arrow dimensions are defined by user specified arrow base height, arrow base width, and arrow head width. (1) Modify the given program to use a loop to output an arrow base of height arrowBaseHeight. (1 pt) (2) Modify the given program to use a loop to output an arrow base of width arrowBaseWidth. Use a nested loop in which the inner loop draws the *’s, and the outer loop iterates a number of times equal to the height of the arrow base. (1 pt) (3) Modify the given program to use a loop to output an arrow head of width arrowHeadWidth. Use a nested loop in which the inner loop draws the *’s, and the outer loop iterates a number of times equal to the height of the arrow head. (2 pts) (4) Modify the given program to only accept an arrow head width that is larger than the arrow base width. Use a loop to continue prompting the user for an arrow head width until the value is larger than the…12. In .............., the bodies of the two loops are merged together to form a single loop provided that they do not make any references to each other. a. Loop unrolling b. Strength reduction c. Loop concatenation d. Loop jamming
- Code in Python Write a function, print_perfect_cubes(n), that takes an integer parameter n and prints the perfect cubes starting from 03 = 0 and ending with n3. When n is negative, the function prints nothing; but do not check for this condition with an "if" statement, it is unneccesary; use a for loop that will automatically print nothing when n < 0. Hint for choosing the right range for your for loop: In the general case, when n is not negative, your function will need to print n+1 different values. For example: Test Result print_perfect_cubes(2) 0 1 8 print_perfect_cubes(5) 0 1 8 27 64 125 print_perfect_cubes(-10)In loop functions.py, define a function named permutations that takes two paramters, n and r, in that order. This function returns the number of different permutations of length r from set of size n. Essentially to calculate these permutations, the function should compute the product (n - r+1)*(n-r+2)*(n-r+3)*...*(n-2)*(n-1) or n!/(n-r)!. No if statements or built in math functions should be used. For or while loops are best reccomended.3. Write a program that accepts two input numbers and compute the Greatest Common Divisor using do-while To get the GCD of another input number, type Y or y; otherwise, type N or n to quit the program. Sample Output: Enter the value of the first number: 10 Enter the value of the second number: The Greatest Common Divisor of 10 and 6 is 2 Type Yly if you want to try again. Type N/n to exit. :