Answer to Question #208378 in C for R SWASTHIK

Question #208378

Mr. John needs to deliver goods from Supermarket to customers house in a two-storey apartment. Owner wants to know the location where John has delivered the goods. The total distance from the store to apartment is 400 steps. To go to 2nd Floor, John need to go 25 steps extra. The distance for 1st floor is less than 25 steps.

If John has crossed more than 425 steps then he has delivered in 2nd Floor. If total steps of John is between 400 to 425 then he has delivered in 1st Floor else John has delivered in Ground floor.

A software need to be developed, to check which floor John has delivered the goods.

Following are requirements to solve the problem

a. Capture the number of steps John used after reaching the building.

b. Add with the distance from Store to apartment. i.e., 400+ steps by John.

c. Compare the total distance travel.

d. Display the appropriate result.


1
Expert's answer
2021-06-18T05:49:40-0400
#include<stdio.h>

int main() {
int steps;
//asking user for number of steps
printf("Enter the number of steps John used after reaching the building: ");
//store the input in steps
scanf("%d",&steps);
//total steps from store to floor
int total_steps=400+steps;
//check if total_steps>425
if(total_steps>425)
//print appropriate statement
printf("John has delivered in 2nd Floor.");
//otherwise check if total_steps is in between 400 and 425
else if(total_steps>400 &&total_steps<=425)
//print appropriate statement
printf("John has delivered in 1st Floor.");
//otherwise
else
//print appropriate statement
printf("John has delivered in ground Floor.");
return 0;
  
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS