First challenge solution


#1

My solution:

[code]#include <stdio.h>

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

// defining and assigning two values
float pi = 3.14;
float meaningOfLife = 42.0;

// defining variable sum and assigning it the sum of two the floats
double sum = pi + meaningOfLife;

// using %.2f instead of %f, so as to output the result with only two decimals
printf(“The sum of pi and meaningOfLife is %.2f\n”, sum);

return 0;

}
[/code]


#2

Thanks for that tip re format specifier. I added this as a second printf statement so my program runs with both formats. Happy days.