954,496 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Understanding Syntax errors for C++

I'm using a program called Dev C++. Sometimes I am able to solve the syntax erros and sometimes I am not able to do so cause I do not understand it although it's logical.
There is an error message which displays "warning: assignment to 'int' from 'double'".
I had to write a program using 4 arrays that are passed into multiple functions. In my program I had to calculate Kilometers per liter and to calculate it I had to first convert miles to Kilometers and convert gallons to liter than dividing the two to obtain the km per liter. Miles and gallons are declared as int arrays and the constant km and liter are declared automatically as double using '#define' so any suggestions!!!!!!

Sef
Newbie Poster
1 post since Aug 2005
Reputation Points: 10
Solved Threads: 0
 

>There is an error message which displays "warning: assignment to 'int' from 'double'".
That's not an error, it's a warning. It's telling you that the fractional part of a floating-point value will be truncated when you assign it to an integer variable. You fix it by using doubles instead of ints.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You