Help me in solving RCPITCP38 problem

My issue

not able to solve the problem

My code

#include <stdio.h>

int main() {
    int s = 14;
    int area = s * s;
    double cost = area * 7;
    
    printf("%d\n", area);
    printf("%d$", cost);

}

Learning course: Learn C Programming
Problem Link: https://www.codechef.com/learn/course/rcpit-programming-c/RCPITLPC07/problems/RCPITCP38

hi man,
Check out this explanation:

int a=3
printf("%d",a) 

since a is an integer we use “%d” format specifier
but in your code:

int main() {
    int s = 14;
    int area = s * s;
    double cost = area * 7; //double datatype
    
    printf("%d\n", area);
    printf("%d$", cost); //for a float value  u specified a integer format specifier

}
}

To fix this. Just change the format specifier to “%f$”
Here’s the code:

#include <stdio.h>

int main() {
    int s = 14;
    int area = s * s;
    double cost = area * 7;
    
    printf("%d\n", area);
    printf("%f$", cost);

}

this fixes the error for good

I do have an another solution feel free to ask me if you want it