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
- 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…Write a new program using your LFSR function from the first problem. Start from state 0x00000001, then run a loop counting all the possible states in the LFSR before it cycles back to 0x00000001. This is shown by the following pseudocode: count = 0; initial = state = 0x00000001; do { state = LFSR(state); count++; while (state != initial); print count; Verify that the number of states is (2^15) - 1 = 32767 . Your program should complete within 30 seconds. If it takes longer then you likely have entered an infinite loop.We write a function that used a loop to print out sin(x) and cos(x) for x = 0 to 90 degrees in 15 degree increments (0, 15, 30, 45, ...) upload the output
- Question 2: Write a program to read student ID and check whether it is odd/even number. Output a 4X4 badge if the student ID is even number and output a 3X3 badge if it is odd number. The badge is built up by the (height X width) of asterisks. (Use for-loop to draw the asterisks, do not hard-coded)A. The original Caesar cypher shifts each character by one: a becomes b, z becomes a, and so on. Let's make it a bit harder, and allow the shifted value to come from the range 1..25 inclusive. Moreover, let the code preserve the letters' case (lower-case letters will remain lower-case) and all non-alphabetical characters should remain untouched. Your task is to write a program which: asks the user for one line of text to encrypt; asks the user for a shift value (an integer number from the range 1..25 - note: you should force the user to enter a valid shift value (don't give up and don't let bad data fool you!) Test your code using the data we've provided. Test data Sample input: abcxyzABCxyz 123 2 Sample output: cdezabCDEzab 123 Sample input: The die is cast 25 Sample output: Sgd chd hr bzrsWrite a Python program that accepts three integer numbers (lo, hi, and fact) from the user. The program should then display all the numbers between ‘lo’ and ‘hi’ (inclusive of both) that are multiples of ‘fact’. See the sample output section for exact input and output formatting requirements. Use a ‘for’ loop in your solution. Implement a solution to the same problem stated above, but this time using a ‘while’ loop instead of a ‘for’ loop.
- In Python: Write a for loop to print each contact in contact_emails.Sample output with inputs: 'Alf' 'alf1@hmail.com' mike.filt@bmail.com is Mike Filt s.reyn@email.com is Sue Reyn narty042@nmail.com is Nate Arty alf1@hmail.com is Alf My code so far: contact_emails = {'Sue Reyn' : 's.reyn@email.com','Mike Filt': 'mike.filt@bmail.com','Nate Arty': 'narty042@nmail.com'} new_contact = input()new_email = input()contact_emails[new_contact] = new_email for new_contact in contact_emails:print('{} is {}'.format(new_email, contact_emails[new_contact])) However it is giving me the wrong output: alf1@hmail.com is s.reyn@email.com alf1@hmail.com is mike.filt@bmail.com alf1@hmail.com is narty042@nmail.com alf1@hmail.com is alf1@hmail.com I dont understand how to separate the contact_names from the contact_emails in the same list.Write a program that does temperature converter :\n", "- The user will enter if he wants the result in Celsius or in Fahrenheit. Use the input function to read this option. \n", "- Ask the user the value of the temperature he wants to convert. Use the input function to read this value and convert accordingly.\n", "- If the user wants the temperature in Fahrenheit compute: $ Fahrenheit = Celsius*5/9+32$.\n", "- If the user wants the Celsius compute as follows: $ C = (F-32)*5/9 $.\n"Write a C++ program that reads integers from standard input and keeps a running sum of all the positive integers that are entered until a negative number is entered. As soon as a negative integer is entered, the program outputs the sum of the positive integers that were read, and then the program ends. If the first number is negative, then the result should be 0. Format your output as in the given examples. Hint: Solve this problem using a while loop. For example: Input Result 4 6 -5 The sum of the positive numbers is 10. -65 The sum of the positive numbers is 0.
- Write a program that uses a User-Defined Function (UDF) that solves for the value of Y as a function of x in the equation shown below: The equation is an infinite series of terms, so the UDF must use an infinite loop to sum up all the terms in the series, add only all terms greater than 1 x. If the term is already less than 1 x, terminate the infinite loop, print the computed value of the sum of the series as the value of y for that value of x on the 2nd column of the Table and the corresponding value of on the 3rd column of the Table shown below which the program must print. The UDF must be declared to be of type void and will accept the value of x as one of its argument and will return its computed value of Y corresponding to that value of x through its reference parameter, &T. The UDF must be declared as: void Y( double x, double &T), use the built-in function to compute the corresponding value of on the 3rd column of the Table. The UDF must be able to compute for…Write a C++ program that continuously requests a donation to be entered using a while-loop or do-whileloop. If the donation is less than 0 or greater than 100, your program should print an appropriate messageinforming the user that an invalid donation has been entered, else the donation should be added to a total.When a donation of -1 is entered, the program should exit the repetition loop and compute and displaythe average of the valid donations entered.Write a function using C that has two integers and uses a loop to count from a lower value to a higher value and vice versa. Use each value of the loop counter as a length in miles and printing it with the corresponding length in KM, with three digits after the decimal point.