Objective c book


#1

Hi guys, first post and so hello to you all.

I am learning programming from scratch for the first time.
I have completed challenge one, and the answer is correct, but i am not sure wether or not my use of double is correct, or even if it’s written properly.

could any of you guys have a look and point out any flaws or suggestions:

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

//Declare 2 variables a and b

float a;
a = 3.14;
float b;
b = 1.86;

//Declare variable to hold the sum of A and B
double C;
c = a + b;

printf("ere %f.\n", c);
return 0;

}

Any help is greatly appreciated!

Thanks


#2

Welcome aboard.

Your code is flawless except for a typo: double [color=#FF0000]C[/color] or double [color=#FF0000]c[/color]?

Posting your code between the Code tags will make it easier for others to view the code:

int main (int argc, const char * argv[])
{
   // Declare and init 2 variables a and b
   float a = 3.14;
   float b = 1.86;

   // Declare variable and init to hold the sum of A and B
   double c = a + b;

   printf ("ere %f.\n", c);
   return 0;
}

#3

So for the late reply, only just logged in and didn’t get an email.

Should the double c be in caps? Not sure what you mean by typo.

I’m trying to maintain good practice from the off, so thanks for your reply!