Kodewick
Start learning →
Starter←→0 / 60

Double the recipe

#025StartervectorLoops3 min

The bakery is making twice as much today. Write double_batch(grams) to multiply each ingredient's grams by 2 and return them in a new vector, in the same order.

Examples
double_batch({200, 50, 3})→[400, 100, 6]
double_batch({})→[]
The functionvector<int> double_batch(const vector<int> &grams)
main.cpp
#include <vector>
using namespace std;

vector<int> double_batch(const vector<int> &grams) {
    vector<int> bigger;
    for (int g : grams) {
        // your code here: put g times 2 into bigger
    }
    return bigger;
}
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.