Daniel
Daniel

Reputation: 3077

Division is not working

I've got a variable:

int Result = 42 % 84;

However its returning null on NSLog?

Upvotes: 0

Views: 355

Answers (3)

John Smith
John Smith

Reputation: 12797

How does it return null in NSLog? Did you write "%@"?

Upvotes: 0

Amy Worrall
Amy Worrall

Reputation: 16337

int r=42%84;
NSLog(@"%d", r);

The above code logs 42 for me.

Upvotes: 2

kennytm
kennytm

Reputation: 523304

To NSLog an integer, use %d.

int result = 42 % 84;
NSLog(@"%d", result);

Upvotes: 6

Related Questions