Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How do I alter this code to exclude negative numbers less than 0 AND non integers such as letters and characters in the following: #include

How do I alter this code to exclude negative numbers less than 0 AND non integers such as letters and characters in the following:

#include

#include

int main ()

{

/* variable definition: */

float distance, sum;

int day;

/* Initialize */

sum = 0.0;

day = 0;

printf("This program will sum up your miles ran or walked each day this week. ");

//While Loop inputs of miles walked each day

while (day <7)

{

printf("Please enter your miles ran or walked today: ");

scanf("%f", &distance);

sum = sum + distance;

day = day + 1;

printf("On day %d, You walked or ran a total of %.02f miles in distance. ", day, distance);

}

// Output completed miles for the week as a sum

printf("Your miles completed this week is %.02f miles. Great Work! " , sum);

return 0;

}

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 3 Lnai 9286

Authors: Albert Bifet ,Michael May ,Bianca Zadrozny ,Ricard Gavalda ,Dino Pedreschi ,Francesco Bonchi ,Jaime Cardoso ,Myra Spiliopoulou

1st Edition

ISBN: 3319234609, 978-3319234601

Students also viewed these Databases questions

Question

Explain the difference between positive face and autonomous face.

Answered: 1 week ago

Question

b. What groups were most represented? Why do you think this is so?

Answered: 1 week ago

Question

3. Describe phases of minority identity development.

Answered: 1 week ago

Question

5. Identify and describe nine social and cultural identities.

Answered: 1 week ago