Message from C, C++ talks

June 2019

— How can i write a c program to print sum and average population of three cities without declaring any other variable except population of three cities
I searched in Google but didn't understand.

Message permanent page

— Print the sum divided by 3?

— I copied the code, why the original programmer has done that? and for atof I got the same error and by including stdlib library eliminate that. why?

Message permanent page

— I declare population as int coz no of people cant be in float
In average i need output in decimal also

Message permanent page

— 

» why the original programmer has done that?
Ask him, I am not the author

» for atof I got the same error and by including stdlib library eliminate that
Because C does not support function overloading. Once you include stdlib there is a declaration for atof. Declaring it in your source file will emit errors

— You can cast it to either a double or an int depending on if you want it to be an integer

— A division of two ints will result in an int

— You'd need to cast the divisor to float

— Ya but without introducing any other variable

— (city1 + city2 + city3)/static_cast<float>(3)

— 🌷👌

— Atoi takes a character pointer

— Thanks 😌

— I am noob
Plz help me in simple words
😅😅😅

— Just copy my code