943,708 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 42714
  • C++ RSS
Jun 6th, 2004
0

Parse error, syntax error, Forbids declaration

Expand Post »
undefinedundefinedundefined

I am needing help on a problem I began a few days ago. It regards a temperature prblem and I am required to write a program to display and print the degrees in farenheit and centigrade. I performed the program numerous times and got these results:
conversion.cpp:11: parse error before `const'
conversion.cpp:25: syntax error before `<'
conversion.cpp:26: syntax error before `>'
conversion.cpp:28: syntax error before `<'
conversion.cpp:29: syntax error before `>'
conversion.cpp:32: ANSI C++ forbids declaration `centiG' with no type
conversion.cpp:32: redefinition of `int centiG'
conversion.cpp:22: `int centiG' previously declared here
conversion.cpp:32: `faren' was not declared in this scope
conversion.cpp:32: `DEGREES' was not declared in this scope
conversion.cpp:33: parse error before `<'
conversion.cpp:35: ANSI C++ forbids declaration `faren' with no type
conversion.cpp:35: `DEGREES' was not declared in this scope
conversion.cpp:36: no match for `int & * _IO_ostream_withassign &'
conversion.cpp:36: parse error before `<'
conversion.cpp:47: syntax error before `{'

This is my program:
//Program 3: Conversion
//Written by: ineedhelp2004
//Date: 06/05/2004
//Course: CSCI 221
//Description: Convert and print temperatures converting Farenheit to
// Centigrade and Centigrade to Farenheit

#include <iostream.h>
#include <iomanip.h>

const float CONVERSION_FACTOR=100.0/180.0
const float FRACTION= 180.0/100.0
const int DEGREES= 32

//Prototype Declarations
float FARENHEIT (float num_1)
float CENTIGRADE (float num_2)

int main (void)
{
//Local Declarations
int faren;
int centiG;

//Statements
cout<< "Enter the Temperature in Centigrade: ";
cin >> centiG;

cout<< "Enter the Temperature in Farenheit: "<<faren<<endl;
cin >> faren;

centiG= CONVERSION_FACTOR* (faren-DEGREES)
cout<<"\nTemperature in Farenheit is: "<<faren;

faren= DEGREES+centiG * FRACTION
cout<<"\nMeasurement in Centigrade is: "<<centiG;

return 0 ;
} //main

//=========================FARENHEIT========================
//Determine the temperature in Farenheit.

float FARENHEIT (centiG)

{
//Statements
faren=DEGREES+centiG*FRACTION

return;
} // FARENHEIT
==========================CENTIGRADE==========================
//Determine centigrade

float CENTIGRADE (faren)

{
//Statements
faren=DEGREES+(centiG*FRACTION)

return;
} //CENTIGRADE

I am new at C++

Can someone please help me??

Thank you

ineedhelp2004
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ineedhelp2004 is offline Offline
2 posts
since Jun 2004
Jun 7th, 2004
0

Re: Parse error, syntax error, Forbids declaration

Hello,

I think there is something wrong with your const declarations above. Instead of

const float CONVERSION_FACTOR=100.0/180.0

I like the idea of:

const float CONVERSION_FACTOR=0.555;

You also forgot the ; after all of the const's in your program.

Christian
Team Colleague
Reputation Points: 121
Solved Threads: 57
Posting Virtuoso
kc0arf is offline Offline
1,629 posts
since Mar 2004
Jun 7th, 2004
0

Re: Parse error, syntax error, Forbids declaration

Quote originally posted by kc0arf ...
You also forgot the ; after all of the const's in your program.
Christian
You also forgot the ; after your funtion declarations

What ever you do in C++ all line have to end with a ; except in a few cases like loops,if elses etc.
Reputation Points: 108
Solved Threads: 7
Posting Whiz in Training
FireNet is offline Offline
256 posts
since May 2004
Jun 7th, 2004
0

Re: Parse error, syntax error, Forbids declaration

Hello my Friend;
i edit your programe and it is working well;
but i notice that the average of this board member are very poor
you must read any book before beginnig to programming
here are you a good book
c++ How to Program
Dietel
There is another thing i notice the using of c old-style libraries
you must use <iostream> instead of <iostream.h>
and so on
Attached Files
File Type: cpp gg.cpp (1.1 KB, 55 views)
Reputation Points: 12
Solved Threads: 2
Newbie Poster
abu_sager is offline Offline
10 posts
since Jun 2004
Jun 7th, 2004
0

Re: Parse error, syntax error, Forbids declaration

Quote originally posted by abu_sager ...
Hello my Friend;
i edit your programe and it is working well;
but i notice that the average of this board member are very poor
you must read any book before beginnig to programming
here are you a good book
c++ How to Program
Dietel
There is another thing i notice the using of c old-style libraries
you must use <iostream> instead of <iostream.h>
and so on
Yes, It is required that we use the old style llibraries with the header files on unix. But still did not compile. Will buy book. Thanks
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ineedhelp2004 is offline Offline
2 posts
since Jun 2004
Jun 7th, 2004
0

Re: Parse error, syntax error, Forbids declaration

hi guys .. how r u ? all
not all members here r poor but they r just beginners and we should learn them as we can okay just step by step don't think that all people like you .. if you learn you must speard ur knowledge.. i am sorry if i wasd rude
Team Colleague
Reputation Points: 55
Solved Threads: 3
Junior Poster
meabed is offline Offline
139 posts
since May 2004
Jun 11th, 2004
0

Re: Parse error, syntax error, Forbids declaration

I guess I would agree with meabed.

No programmer is poor unless he calls himself a programmer and does not put any effort into programming.
Reputation Points: 108
Solved Threads: 7
Posting Whiz in Training
FireNet is offline Offline
256 posts
since May 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Cubing Digits Individually
Next Thread in C++ Forum Timeline: practice(newbie)





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC