Constexpr ADC Temperature Table

#include <iostream>
using namespace std;




constexpr int TEMP_TABLE[] = {-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;
}

Solving Approach

 

 

 

 

 

 

Upvote
Downvote
Loading...

Expected Output

-40