/***********************************************************
RP_cars2.ch
Ratios and Proportions
This program improves on RP_cars1.ch Once we have identified
patterns that lead us to formula, we can write a second,
shorter, algorithm. This algorithm is based on the idea that
if we divide the total white cars by the number of white
cars made for every 5 blue cars, and multiply the result by
the number of blue cars made for every 3 white cars, we
will get the total number of blue cars.
************************************************************
Copyright 2014 SoftIntegration Inc.
http://www.softintegration.com
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
***********************************************************/
// initialize variables
int white, blue, totalwhite, totalblue;
// assign variables values
white = 3;
blue = 5;
totalwhite = 15;
// calculate proportion
totalblue = (totalwhite/white)*blue;
printf("The company makes %d blue cars.\n", totalblue);