....And I need some guidance with Chapter 4 Exercise 2
The task is fairly simple
------------------------------------------------------------------------
2: Write a program that converts 27° from degrees Fahrenheit (F) to degrees Celsius (C) using the following formula:
C = (F - 32) / 1.8
-------------------------------------------------------------------------
Okay so this is fairly straight forward but I want to go one step further and instead of hard coding the Fahrenheit temperature into the program I decided to try to write something that will take a Fahrenheit temperature from the user and then do the math and then output the Celsius result.
And here I am running into a wall. Now please understand I have no formal programming education. But I have been working in IT Desktop Support for a couple of years and I am now trying to expand my horizons and learn programming and I figured that since the Mac is my platform of choice for personal use I would first start trying to write for it. So any ways on to the code itself (I know it looks awful but I am trying to get better)
--------------------------------------------------------------------------
#import <stdio.h>
main()
{
float 'Celsius';
float 'Fahrenheit';
Celsius = (Farhrenheit - 32) / 1.8;
printf ("Input Fahrenheit Temprature\n");
scanf Fahrenheit;
printf Celsius;
}
--------------------------------------------------------------------------
When I try to compile with GCC I get the following
--------------------------------------------------------------------------
the-house-2:Chapter 4 brian$ gcc Exercise\ 2.m -o Exercise2 -l objc
Exercise 2.m:7:8: warning: character constant too long for its type
Exercise 2.m: In function main:
Exercise 2.m:7: error: syntax error before '\x73697573'
Exercise 2.m:8:8: warning: character constant too long for its type
Exercise 2.m:10: error: Celsius undeclared (first use in this function)
Exercise 2.m:10: error: (Each undeclared identifier is reported only once
Exercise 2.m:10: error: for each function it appears in.)
Exercise 2.m:10: error: Farhrenheit undeclared (first use in this function)
Exercise 2.m:13: error: syntax error before Fahrenheit
the-house-2:Chapter 4 brian$
--------------------------------------------------------------------------
Now what I don't understand is that it seems to me that it is mainly complaining about not having declared the variables Celsius and Farhrenheit but the declaration is right there in the beginning of the program. What am I doing wrong here?
Thanks in advance
.
The task is fairly simple
------------------------------------------------------------------------
2: Write a program that converts 27° from degrees Fahrenheit (F) to degrees Celsius (C) using the following formula:
C = (F - 32) / 1.8
-------------------------------------------------------------------------
Okay so this is fairly straight forward but I want to go one step further and instead of hard coding the Fahrenheit temperature into the program I decided to try to write something that will take a Fahrenheit temperature from the user and then do the math and then output the Celsius result.
And here I am running into a wall. Now please understand I have no formal programming education. But I have been working in IT Desktop Support for a couple of years and I am now trying to expand my horizons and learn programming and I figured that since the Mac is my platform of choice for personal use I would first start trying to write for it. So any ways on to the code itself (I know it looks awful but I am trying to get better)
--------------------------------------------------------------------------
#import <stdio.h>
main()
{
float 'Celsius';
float 'Fahrenheit';
Celsius = (Farhrenheit - 32) / 1.8;
printf ("Input Fahrenheit Temprature\n");
scanf Fahrenheit;
printf Celsius;
}
--------------------------------------------------------------------------
When I try to compile with GCC I get the following
--------------------------------------------------------------------------
the-house-2:Chapter 4 brian$ gcc Exercise\ 2.m -o Exercise2 -l objc
Exercise 2.m:7:8: warning: character constant too long for its type
Exercise 2.m: In function main:
Exercise 2.m:7: error: syntax error before '\x73697573'
Exercise 2.m:8:8: warning: character constant too long for its type
Exercise 2.m:10: error: Celsius undeclared (first use in this function)
Exercise 2.m:10: error: (Each undeclared identifier is reported only once
Exercise 2.m:10: error: for each function it appears in.)
Exercise 2.m:10: error: Farhrenheit undeclared (first use in this function)
Exercise 2.m:13: error: syntax error before Fahrenheit
the-house-2:Chapter 4 brian$
--------------------------------------------------------------------------
Now what I don't understand is that it seems to me that it is mainly complaining about not having declared the variables Celsius and Farhrenheit but the declaration is right there in the beginning of the program. What am I doing wrong here?
Thanks in advance