# The First Challenge. Ugggh!

I’m 43 years old and desperately want to learn Objective C. I have zero experience but have already run into a problem on my very first challenge.

I really need help understanding the type ‘double.’ There’s a brief explanation about what it is in the chapter but no real examples. So when I try to do the challenge, the syntax is correct, but the ‘double’ part never shows up in the ‘print’ function. How can this be resolved. And remember, no computer lingo. I’m really illiterate except for a few things here and there. Thanks.

Steven

Hello, Stephen

Cheers,
D.

[quote]I’m 43 years old and desperately want to learn Objective C. I have zero experience but have already run into a problem on my very first challenge.

I really need help understanding the typedouble.’ There’s a brief explanation about what it is in the chapter but no real examples. So when I try to do the challenge, the syntax is correct, but the ‘double’ part never shows up in the ‘print’ function. How can this be resolved. And remember, no computer lingo. I’m really illiterate except for a few things here and there. Thanks.

Steven[/quote]
Hi Steven,

Variables of type double are used to store real numbers.

Broadly speaking, the set of real numbers include any number you can think of: for example, -3.5, -1, 0, 0.00001, 0.7, 1, 2, 2,9, 2.99, 2.999999999999999, 3, 16, etc.

The following code demonstrates how to print a real number by using the printf function.

``````#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{
const double value = 2.3271819;

// print
printf ("%f\n", value);

// print with specified number of digits after decimal point...
//
// No digits
printf ("%.0f\n", value);

// 2 digits
printf ("%.2f\n", value);

// 12 digits
printf ("%.12f\n", value);

// Again...
printf ("\n");

int numDigits = 0;
printf ("%.*f\n", numDigits, value);

numDigits = 1;
printf ("%.*f\n", numDigits, value);

numDigits = 2;
printf ("%.*f\n", numDigits, value);

numDigits = 12;
printf ("%.*f\n", numDigits, value);

return 0;
}``````

Hope this helps.

[Become a competent programmer: pretty-function.org]