Super simple program does not work

I am working on the book "Programming in the lens with 2.0", and I do not understand why this program does not work. basically i need to build a program to convert fahrenheit to celcius.

I decided to just solve it very simply without objects and just use a straightforward procedural methodology, since the problem I am facing is that the values ​​of the variables that I define to represent the values ​​in Fahrenheit or Cellus are random.

Here is my code:

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    float  fahrenheit;
    float  celciusConverted;
    fahrenheit = 27.0;
    celciusConverted = ( fahrenheit - 32 ) / 1.8 ;
    NSLog(@"%f degrees fahrenheit is equal to %f degrees celcius") , fahrenheit, celciusConverted;
    [pool drain];
    return 0;
}
+3
source share
2 answers

The closing bracket in your NSLog statement is inappropriate. It should be just before;

You have

NSLog(@"... %f %f ..."), arg1, arg2;

, , %f , , NSLog(). , arg1 arg2 .

+5

.

NSLog(@"%f degrees fahrenheit is equal to %f degrees celcius", fahrenheit, celciusConverted);
+3

Source: https://habr.com/ru/post/1726913/


All Articles