Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C program For Loops For each of the programs assigned below. submit a copy of the source code (.c and a sample execution, saved as

image text in transcribed

C program

For Loops For each of the programs assigned below. submit a copy of the source code (.c and a sample execution, saved as an electronic attachments to Assignment 5 located in Canvas under Assignments. (You may copy the black or, preferably, white screen to a Word document by using CTRL PRINTSCREEN and then CTRLV. You may put all executions in the same document.) Observe the usual guidelines regarding the initial comment section, indenting, and so Do not use global variables. on. 1. Modify the guess-a-number program from the while2 classwork, using a for loop. so that the user is allowed only 3 guesses. You may need to use a break statement to exit the loop if the user guesses correctly 2. Write a program to find the approximation of In(10) using the following formula for m terms: ben 10) 19/10) where n=1,2,...m Prompt the user to enter the number of terms between 10 and 50 inclusive) to be used in the approximation. Use a while validation loop to assure that the number of terms is in the proper range. Use a for loop to calculate each term in the sum and while doing so, to print a table. Each line of the table should include the term (value of n) number, the value of the term added to the sum at that iteration accurate to 5 decimal digits, and the value of the sum at that iteration also printed with 5 decimal digits. Use doubles for the term and sum approximation values. At the end of the program print the final value of the sum and also the actual value of In(10) from the Clibrary using 5 decimal digits. The first two lines of the table will look like this: 11 1 2 Term 0.9000 0.40500 Sum 0.90000 1.30500 3. Write a program to find the largest of 20 random numbers and the number of times the maximum appears in the list. Declare variables. Seed the random number generator with the time of day. Initialize the variables for maximum and count. On each pass through a for loop Generate a random number between 1 and 15. assign it to the random number variable, and print it. . Check to see if it is larger than the maximum. If it is a new maximum, assign to maximum. If the number is equal to the maximum add to count accordingly . Upon exiting the loop, print the maximum and the number of times it appears in the list

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

More Books

Students also viewed these Databases questions

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago