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;
    cout<< TEMP_TABLE[idx];
    // Print the value from TEMP_TABLE based on idx

    return 0;
}

Solving Approach

 

 

 

 

 

 

Upvote
Downvote
Loading...

Expected Output

-40