Question: a. Write a scanf statement to read in one number (int), and another statement to print out that number. b. Write a for loop to

 a. Write a scanf statement to read in one number (int),

a. Write a scanf statement to read in one number (int), and another statement to print out that number. b. Write a for loop to read in a series of 5 numbers (int), each iteration reading one number and printing it out. c. Write one scant to read in three integers into variables standing for beach number (int), number of samples (int), number of organisms per 100 ml of water (int). Choose appropriate names for the variables like: b_num, num_samples, num_orgs...per_100. d. Write a scanf line to read in an integer "number of samples from the keyboard into the variable num_samples. Following that, write a for loop to iterate (repeat) num_samples times. In each iteration have your code read in one value from the keyboard into a variable (any name will do, here) and print it out. eg: If num_samples is 8, your code will read a value in the first line of the body of the for loop and then print it out in the next line, repeated a total of 8 times. Note that each new read overwrites the previous value in your variable. REMEMBER: a loop (for or while, and also if and else for that matter) ALWAYS executes ONLY a SINGLE statement - which means that you do NOT need curly braces around that one statement. If you want your for loop to execute two statements (scanf in the value, and then print it out), they both must be put into a "compound statement" (any number of statements inside curly braces). This compound statement acts like a single statement insofar as the for loop is concerned, so the single compound statement that is, the two statements it contains) is executed once each time the for loop iterates. e. Now slightly modify the for loop code as follows. Continue to use the scanf line to read in the number of samples into the variable num_samples, before the for loop code. However, this time have each read place each value into the variable named num_orgs_per_100 ... and then, as before, print out each in the second line of the compound statement. (Note that each subsequent read will overwrite the value in num_orgs_per_100 from the previous read, just as happened in the previous section. We will do something different with those values, below.) f. This step introduces and arranges data. Your coding is not changed in this part. In the above, your data has come from the keyboard. You can continue to do that, but putting the data in a file (input with redirection or FILE 1/0) will certainly cut down on your work during debugging. Type in your data or create your data file so that each data line has the following information: two integers: the beach number and the number of samples; followed by (on the same line): a series of numbers which are the number of organisms per 100 ml of water for each sample. These will eventually go into variables b_num, num_samples, and repeatedly (as you did, above) into num_orgs_per_100. eg for beach number 17 with 3 samples: 17 3 2500 3450 1825 You will eventually write a while loop in your coding (not yet) which will scanf values into b_num and num_samples. The while loop will be written to stop when the beach number is -17. The data could look like this: 18 14 -17 3 2 0 2500 4800 3450 6000 1825

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!