Constexpr ADC Temperature Table

#include <iostream>
using namespace std;

// Create constexpr lookup table here:
constexpr int TEMP_TABLE[6] = {-40, -10, 20, 50, 80, 120};

int main() {
    int idx;
    cin >> idx;

    // Print the value from TEMP_TABLE based on idx
    cout << TEMP_TABLE[idx];

    return 0;
}
Upvote
Downvote
Loading...

Input

0

Expected Output

-40