Compute ADC Voltage Scale

#include <iostream>
#include <cstdint>

using namespace std;

// TODO: Implement constexpr int32_t computeScale(int32_t maxAdc, int32_t maxVoltage_mV)
// TODO: Define constexpr int32_t SCALE_UV = ...
constexpr int32_t computeScale(int32_t maxAdc, int32_t maxVoltage_mV)
{
    return (maxVoltage_mV * 1000) / maxAdc;
}


int main() {
    int32_t x;
    if (!(cin >> x)) return 0;

    // TODO: Compute voltage_uv using SCALE_UV
    // TODO: Print the result
    constexpr int32_t SCALE_UV = computeScale(4095, 3300);
    cout << SCALE_UV * x;

    return 0;
}

Solving Approach

 

 

 

 

 

Upvote
Downvote
Loading...

Input

0

Expected Output

0