Compute ADC Voltage Scale

#include <iostream>
#include <cstdint>

using namespace std;

constexpr int32_t computeScale(int32_t maxAdc, int32_t maxVolatage){
    return (maxVolatage * 1000) / maxAdc;
}

constexpr int32_t SCALE_UV = computeScale(4095, 3300);

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

    int32_t voltage_uv = x * SCALE_UV;
    cout << voltage_uv;
    
    return 0;
}

Solving Approach

 

 

 

 

 

Upvote
Downvote
Loading...

Input

0

Expected Output

0