| | |
type conversion
![]() |
•
•
Join Date: Sep 2004
Posts: 24
Reputation:
Solved Threads: 0
Hi!
I have problem with type conversion.
when I compile the program I get this error:
( 'count' : redefinition; different basic types ).
please tell me about type conversion.
I have problem with type conversion.
when I compile the program I get this error:
( 'count' : redefinition; different basic types ).
please tell me about type conversion.
C Syntax (Toggle Plain Text)
#include<stdio.h> int count(double houre, double charge); int main(){ double h=4; double c=2; printf("%d\n", count(h,c)); return 0; } int count(double houre, double charge){ double value; if(houre<=3.0) { return charge; } else { value=(2+(0.5*(houre-3))); return value; } return 0; }
int count(double houre, double charge){
double value;
if(houre<=3.0)
{
return charge;
}
else
{
value=(2+(0.5*(houre-3)));
return value;
}
return 0;
}value is double type and count function is return int type, it is possible ?
>value is double type and count function is return int type, it is possible ?
Yes, but a decent compiler will warn you about a loss of precision.
>compiler:Micrisoft visual c++ 6
Hmm, I'm going to chalk this one up as a "Visual C++ 6 sucks ass" issue. Change the name of your function to something less standard and more meaningful to your intentions:
Yes, but a decent compiler will warn you about a loss of precision.
>compiler:Micrisoft visual c++ 6
Hmm, I'm going to chalk this one up as a "Visual C++ 6 sucks ass" issue. Change the name of your function to something less standard and more meaningful to your intentions:
C Syntax (Toggle Plain Text)
#include<stdio.h> double calc_charge(double houre, double charge); int main(){ double h=4; double c=2; printf(".2f\n", calc_charge(h,c)); return 0; } double calc_charge(double houre, double charge){ double value; if(houre<=3.0) { return charge; } else { value=(2+(0.5*(houre-3))); return value; } }
I'm here to prove you wrong.
![]() |
Similar Threads
- A doubt in Type Conversion Program (C++)
- Data loss in Type Conversion. (C++)
- help on data type conversion (Visual Basic 4 / 5 / 6)
- automatic type conversion (PHP)
Other Threads in the C Forum
- Previous Thread: monolithic copying
- Next Thread: C + Assembler = something I can't solve
| Thread Tools | Search this Thread |
#include * ansi array arrays asterisks binarysearch calculate centimeter changingto char character convert copyanyfile copyimagefile cprogramme creafecopyofanytypeoffileinc createprocess() database dynamic execv fgets file floatingpointvalidation fork function getlogicaldrivestrin givemetehcodez grade gtkwinlinux hacking histogram ide inches include incrementoperators infiniteloop input interest intmain() iso kernel keyboard kilometer km license linked linkedlist linux list looping lowest matrix meter microsoft number oddnumber open opendocumentformat openwebfoundation owf pdf pointer posix power probleminc process program programming pyramidusingturboccodes radix read recursion recv recvblocked research reversing scheduling segmentationfault send sequential single socket socketprogramming standard strchr string suggestions systemcall test threads turboc unix urboc user variable wab whythiscodecausesegmentationfault win32api windowsapi






