Video Tutorial: Objective-C Data Types: Float

Learn about the float data type in Objective-C, including what you need to know about floats and accuracy in practice. By Ray Wenderlich.

Leave a rating/review
Save for later


Hide contents

Video Tutorial: Objective-C Data Types: Float

0 mins


Your challenge is to add this code to your project, fill in the question marks, and answer the question:

float account1 = 100.00;
float account2 = 0.00;
float transferAmount = 0.1;

for(int i = 0; i < 30; i++) {
    account1 -= transferAmount;
    account2 += transferAmount;

NSLog(@"Account 1: %???", account1);
NSLog(@"Account 2: %???", account2);
NSLog(@"Sum: %???", account1 + account2);
// Explain: what went wrong here?

Download solution

Helpful links


Over 300 content creators. Join our team.