This was how I did my first challenge

Hello,

Just wanted to share with you guys how I completed my first challenge. I don’t know if this is completely correct but I hope it’s along the lines. I’m used to C++ so I started using int’s to store my variables in but that’s not what the challenge was asking so I changed things up a bit to fit the challenge. Anyways, here’s my code, and I don’t use the modern C technique ( float = ) I just use what the book taught me so far.

#include <stdio.h>

int main(int argc, const char * argv[])
{
    float chal1;
    
    chal1 = 15.6;
    
    float chal2;
    
    chal2 = 23.2;
    
    double add;
    
    add = 13.2;
    
    printf("The two floats equals %f", chal1 + chal2);
    
    double sum;
    sum = chal1 + chal2;
    
    printf("Together with the double they equal %f", add + sum);

    return 0;
}

I could probably have used something else for the sum instead of the double but I couldn’t think of anything else to use that could store the values together, assuming I can’t use int.

I notice one error but i am unsure if you intentionally did that.

the values for the variable are incorrect.

The logic you used was correct
here is another way. this is how i solved it

#include <stdio.h>

int main(int argc, const char * argv[])
{

    // Declare the variables
    float   f_Num1,  f_Num2;
    double  d_Sum;
    
    // Initialize variables
    f_Num1 = 3.14;
    f_Num2 = 42.0;
    d_Sum = f_Num1 + f_Num2;
    
    // Print the sum
    printf( "The sum of %f and %f is %f . \n" , f_Num1 , f_Num2 , d_Sum);

    return 0;
}

Hope this helps…