Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PROGRAMMING LANGUAGE C QUESTION #4 You are now allowed to use the following in additional to the techniques of the previous chapters: for loops math.h
PROGRAMMING LANGUAGE C
QUESTION #4
You are now allowed to use the following in additional to the techniques of the previous chapters:
for loops
math.h and pow() function
formatting float and double numbers
switch statements getchar() function
ASCII chart
dowhile loops
break and continue statements
Logical AND (&&), logical OR (||), logical NOT (!) operators
d file://C:/Users/Valeria%20Moctezuma/Downloads/Homework-04-Spring-2018.pdf Homework-04-Spring-2018.pdf 212 Q3: (Bar Charts) (25 Points) Write a program that reads in a series of integers in the range of 1 to 40, with the first number indicating how many integers follow it. Print out a bar chart of the numbers entered. For example, if the following is entered at a prompt Enter integers between 1 and 40 (first number indicates how many there are): 3 10 13 9 You should output the following (13) Q4: (Approximating ) (25 points) The value of can be approximated with the infinite series as follows: 1 3 5 79 11' Write a program that determines how many terms in takes using the above infinite series to approximate to 3.14159. You can state the answer to this question in the word document you submit, if you obtain the answer through trial and error Bonus (5 points): Your program should stop itself when the precision is met and output the following: It took n terms to approximate pi to 3.14159. Hint: Think about a numerator and a denominator. You learned in a previous homework how to generate odd number sequences. Pay close attention to the sign of each term. Casting: You can eliminate all numbers beyond the 5th decimal position using casting, such as int a - (int)(3.14159265 100000). Here a float is being multiplied by an integer, with the result being a float. The decimal point has been moved 5 places to the right. Use (int) to "cast" that into an integer, truncating all the decimals of the new number, resulting in the new number 314159 O Type here to search 2/18/2018
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started