A war game is conducted between two countries A and B. Country A at its Air Force Base in Rimnicu Vilcea has some Rockwell B-1 Lancer Heavy Bombers and some Mitsubishi F-3 Fighters. Since bombers are comparatively slow and are not easily maneuverable each bomber should be accompanied by at least a squadron of three fighters. Rimnicu Vilcea Air Force Base has over 5000 liter of fuel, 200 pilots, 4 wing commanders and an Air Marshal. Moreover, enemy airfields of Sibiu and Fagaras are within reach of the bombers from Rimnicu Vilcea. So, airfields of Rimnicu Vilcea should remain operational, it is vital for winning the war. According to Air Marshal Prince Constantin Cantacuzino, “we need at least 10 fighters in the air to defend against their first wave of attack”.
Assume that both Rockwell B-1 Lancer Heavy Bomber and Mitsubishi F-3 Fighter can be operated by a single pilot. Assume that all the pilots, wing commanders and Air Marshal are competent pilots but due to tactical reasons Air Marshals are not allowed to participate in any flying missions.
Write a C program to read the number of fighters and bombers from the user and identify the maximum numbers Rockwell B-1 Heavy Bombers that can be sent on a bombing run at a time by country A so that airfields of Rimnicu Vilcea won’t be vulnerable to air raids from Country B’s bombers?
You have input the number of fighter first followed by the number of bombers.
Sample Input/Output
Input:
0 0
Output
0
#include <stdio.h> int main() { // declare variables int numFighters; // number of fighters int numBombers; // number of bombers // read inputs // first number of fighter then number of bombers scanf("%d %d", &numFighters, &numBombers); // decrement number of fighter by 10 numFighters -= 10; int numPilots = 194; // 200 pilots - 4 wing commanders int numBombersSent = 0; // let the number of bombers to sent be zero // run loop until // a squadron have at least three fighters, and // number of bombers greater than zero, and // have at least 4 pilots while (numPilots >= 4 && numFighters >= 3 && numBombers > 0) { numBombersSent += 1; // send one bomber numBombers -= 1; // and reduce and update bomber count numFighters -= 3; // reduce and update fighters numPilots -= 4; // reduce and update pilots } // print the computed number of // bombers to sent printf("%dn", numBombersSent); return 0; }#include <stdio.h> int main() { // declare variab ... See the full answer