Challenge 1


#1

I don’t understand the challenge. how do i go about it?? its not saying what to name the floats. Can i get a clear understanding on how to go about it.


#2

You can name the floats anything you want. Just name 2 floats anything, assign a value to each and then printf it to the screen.


#3

This is how mines is. Just thought you could use it as a reference if you need it.

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

float number1;

number1 = 1.0;

float number2;

number2 = 2.0;

double sum;

sum = 1.0 + 2.0;

printf(“The sum of two floats is %f.\n”, sum);

return 0;

}


#4

Just a slight correction, if I may: I believe the following line

sum = 1.0 + 2.0;

should be

sum = number1 + number2;

In order to take advantage of the variables you’ve set instead of providing the same literal values again. Obviously the result is the same, and if I’ve learned anything in programming it’s that there’s a lot of ways to do the same thing, just wanted to point it out :slight_smile:


#5

[quote=“mclifford82”]Just a slight correction, if I may: I believe the following line

sum = 1.0 + 2.0;

should be

sum = number1 + number2;

In order to take advantage of the variables you’ve set instead of providing the same literal values again. Obviously the result is the same, and if I’ve learned anything in programming it’s that there’s a lot of ways to do the same thing, just wanted to point it out :slight_smile:[/quote]

Thank you! By the way I haven’t touched my book in a while due to classes. But I was wondering if I you have finished it? If you have would you be able to help me out on the challenge solutions if I need any? I would like to e-mail you if that’s alright. You know helping each programmer out? I’d greatly appreciate it, thank you!