Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Code in c uild Prelab 3 Submission Information Submit this assignment by following using the lab code given by the TA Use the following submit

Code in c image text in transcribed
image text in transcribed
image text in transcribed
uild Prelab 3 Submission Information Submit this assignment by following using the lab code given by the TA Use the following submit comman For example: ng the instructions given by your TA SUBMIT ONLY the equired). All of the lab assignments must be submitted before the end of the lab file (no a.out in submit cassignment> submit CS1050 Lab 3 m-lab3.c Filename must be: sectionletter-lab3.c (include your respective lab section), e.g., c-lab3.c Description For the lab assignment, you may not also use the if statement nor may you use the if/else statement. You may not use a while statement. You are to write a program that calculates summations from 0 up to and including a maximum number given by the user. If a user enters a negative number,issue an error message and do not process the negative number. Note that since you cannot use an if or if/else statement, you may want to think about using a Boolean in a switch statement, or perhaps combining a switch with a ternary operator to determine how to handle a negative number. BONUS: At the end of the program, print the largest summation you calculated Sample Output 1 (bold and underline shows user input) 3imR@31mRArea51: compile m-lab3.c JimR@3imRArea51:$ ./a.out Enter the high limit of the sumation you wish to calculate: -5 Error: You must enter a non-negative number Enter 8 to quit or 1 to continue: 1 Enter the high limit of the summation you wish to calculate: Error: You must enter a non-negative number Enter e to quit or 1 to continue: 1 Enter the high limit of the summation you wish to calculate: 5 Calculating summations up to5 Summation(e..0)e Summation (..1) 1 Summation(e..2)3 Summation (..3)6 Summation(e..4) 10 Summation(e..5)15 Enter to quit or 1 to continue : 1 Enter the high limit of the summation you wish to calculate: 1 Calculating summations up to 10 Summation(e..0) Summation(e..1) 1 Summation(e..2) 3 Summation(e..3) 6 Summation(e..4) 10 Summation(0, .5) 15 Summation(0.6) = 21 Summation(0, .7) 28 Summation(0..8) 36 Summation(0..9) 45 Summation(0, .18)55 Enter 0 to quit or 1 to continue: e The largest summation you calculated was 55 Guidelines for Grading Lab 3 40 Points Possible (+5 points Bonus) 195 General If your program does not points compile, or produce any input/output then your lab will receive a grade of zero 5 points: Header, comments, and general coding style. 10 points: Correctly writing the summation loop. 10 points: Correctly calculating summations for positive numbers 5 points: Correctly looping until the user says "O" (do not continue). 10 points: Using a switch (or something other than an if statement) to detect that the user entered a negative number 5 points [BONUS]: Finding the largest summation for the whole program run

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, Elizabeth O'Neil

2nd Edition

1558605800, 978-1558605800

More Books

Students also viewed these Databases questions

Question

How would you respond to each of the girls?

Answered: 1 week ago