Task using C language Two spacecrafts are traveling at different speeds from Earth to Mars. While spacecraft A doubles its speed every day, spacecraft B triples its speed in the same period. Given their initial speeds, your task is to determine how many days spacecraft B will

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 20PE: When you borrow money to buy a house, a car, or for some other purpose, you repay the loan by making...
icon
Related questions
Question

Task using C language

Two spacecrafts are traveling at different speeds from Earth to Mars. While spacecraft A doubles its speed every day, spacecraft B triples its speed in the same period. Given their initial speeds, your task is to determine how many days spacecraft B will take to travel faster than spacecraft A.

  • If the initial speed of spacecraft A is 7, it will be 14 after 1 day, 28 after 2 days, and so on.
  • If the initial speed of spacecraft B is 4, it will be 12 after 1 day, 36 after 2 days, and so on.
  • If the initial speed of spacecrafts A and B are 7 and 4, respectively, B will be faster than A after 2 days, as the speed of A will be 28 and the speed of B will be 36.

Requirements

  1. Follow the format of the examples below.
  2. You will be given several test cases in a single run, and you must provide an answer for all of them.
  3. Use #define

Examples (your program must follow this format precisely)

Example #1

Number of cases: 3
Speed of A: 7
Speed of B: 4
Case #1: 2 day(s)
Speed of A: 4
Speed of B: 4
Case #2: 1 day(s)
Speed of A: 4
Speed of B: 7
Case #3: 0 day(s)

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Computational Systems
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr