Repair both sides of formatted input/output

The broken program should read an int units, a double price and a non-whitespace character grade, even when grade is on the next line. Valid numeric tokens are representable in their destination types. For input 3 2.5 followed by a newline and A, the required output is units=3 price=2.50 grade=A. Print invalid if fewer than three conversions succeed.

    Identify every address/type/whitespace defect and provide a corrected complete program. Explain why scanf needs %lf for this price while printf uses %.2f. Do not attempt to predict output from the broken program; its mismatched variadic arguments can cause undefined behavior.

#include <stdio.h>
int main(void)
{
    int units;
    double price;
    char grade;
    scanf("%d %f%c", units, &price, &grade);
    printf("%d %.2f %s\n", units, price, grade);
    return 0;
}

