Hi all,
I’m brand new to programming and thought to get started with Objective-C Programing and already have run into a problem that I can not seem to figure out or get working properly. In the section “A program with variables” the book has me starting a new project labeled Turkey and to write into Xcode the exact text/code depicted in the book. I do (without any typos), however when running the program I consistently get a “Use of undeclared identifier ‘weight’” error. I’ve followed the instructions in the book exactly and I don’t see why this error is happening. I’ve read a bit further on to see if this error was supposed to happen and that I would be shown why, but nothing. The very next thing is the 1st challenge. Could this be that I am using a much newer version of Xcode from when this book was first written? And if so, is there a more recent edition that I should be working from instead of the 2nd Edition.
#include <stdio.h>
int main(int argc, const char * argv[])
{
// Declare the variable called ‘weight’ of type float float weight;
// Store a number in that variable
weight = 14.2;
// Log it to the user
printf("The turkey weights %f.\n", weight);
// Declare another variable of type float
float cookingTime;
// Calculate the cooking time and store it in the variable
// In this case, '*' means 'multipled by'
cookingTime = 15.0 + 15.0 * weight;
// Log that to the user
printf("Cook it for %f minuets.\n", cookingTime);
// End this function and indicate success
return 0;
}