- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

In this problem, we are given two integers that give the head start that is given by A to B and C respectively in a 100-meter race. Our task is to create a *program to find the head start in a race in C++*.

**Code Description** − Here, there are head starts that are given by A to B and A to C respectively in a 100-meter race. We need to find the relative head start that is given by B to C in the 100-meter race.

**Let’s take an example to understand the problem,**

20, 28

90

A gives B a head-start of 15 i.e. if A completes 100 m, then B completes 80.

A gives C a head-start of 28 i.e. if A completes 100 m, then B completes 72.

Now, when B completes 80 meters, C completes 72.

If B completes 100, C completed

(72 * 100) / 80 = 90

To solve the problem, find the distance that B and C complete when A completes 100 meters. After this we calculate the distance that C completes when B completes 100, using the formula −

(C * 100) B

**Program to illustrate the working of our solution,**

#include <iostream> using namespace std; int CalcHeadStart(int B, int C) { return ( 100 - ( ( (100 - C)*100 ) / (100 - B)) ) ; } int main() { int B = 12, C = 34; cout<<"Head start in a race by B to C is "<<CalcHeadStart(B, C) << " meters"; return 0; }

Head start in a race by B to C is 25 meters

- Related Questions & Answers
- Race Car in C++
- Automate Mobile Testing to Win The Race
- Find kth node from Middle towards Head of a Linked List in C++
- C++ program to find smallest and largest number of children in game before start
- What is a rat-race junction in microwaves?
- Different ways to start a Task in C#
- C++ program to find minimum number of steps needed to move from start to end
- Program to find all contiguously increasing numbers in start end range in Python
- Program to find number of possible moves to start the game to win by the starter in Python
- Program to find start indices of all anagrams of a string S in T in Python
- C++ Program to Find the Mode in a Data Set
- C++ Program to Find the Maximum Cut in a Graph
- Program to find the Area of a Parallelogram in C++
- Program to find the Area of a Pentagon in C++
- Program to find the angles of a quadrilateral in C++

Advertisements