Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 error, idk how to fix...
Index -> Programming, C -> C Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Aenoc




PostPosted: Wed Nov 05, 2008 8:34 pm   Post subject: error, idk how to fix...

here is my code,,.... it has 2 functions, 1 to raise a float number. say 3.4 to 4, and 1 to lower a float say 3.4 again, to 3....
when i compile the program it reads two errors.
1) line 28: warning: old-style declaration or incorrect type for: Uceil
2) line 36: warning: old-style declaration or incorrect type for: Ufloor
can anyone help???. its just practise for a midterm so no marks for it but i dont get why its doing it.. lol so may cause things on midterm...

code:
#include <stdio.h>

/* function proto.s */
int Uceil  (float);
int Ufloor (float);

void main(void)

{

float num1, num2, num3, num4;
int   V;

printf ("Please type in the values of the 4 numbers.\n");
scanf ("%f %f %f %f", &num1, &num2, &num3, &num4);

V = (Uceil(num1) + Ufloor(num2) - Uceil(num3)) * Ufloor(num4);

printf ("The expression is V = (Uceil(%f) + Ufloor(%f) - Uceil(%f)) * Ufloor(%f).\n", num1, num2, num3, num4);
printf ("The resulting value is: %d.\n", V);

}

/* function definitions */

Uceil (float num_up)

{
int tempV;
tempV = (int) num_up++;
return (tempV);
}

Ufloor (float num_dwn)

{
int tempV;
tempV = (int) num_dwn;
return (tempV);
}



Mod Edit: Remember code tags! Smile
code:
[code]Code Here[/code]
Sponsor
Sponsor
Sponsor
sponsor
OneOffDriveByPoster




PostPosted: Wed Nov 05, 2008 9:44 pm   Post subject: Re: error, idk how to fix...

You have
c:
void main(void)

and
c:
Uceil (float num_up)
.

Both are bad.

The first because main() should be declared to return int in standard C.
The second because you are missing the return type--that is, you are using "implicit int".

There are more issues really, but I think you could figure them out.
Aenoc




PostPosted: Wed Nov 05, 2008 9:51 pm   Post subject: Re: error, idk how to fix...

ok that was a quick fix =P sumtimes im stupid. thx
wtd




PostPosted: Wed Nov 05, 2008 10:21 pm   Post subject: RE:error, idk how to fix...

It's not your fault that you missed the fixes.

C is a very permissive language. You can make mistakes and it'll still work... but just in some different way than you expected. Experience gives you the ability to deal with this effectively.
Display posts from previous:   
   Index -> Programming, C -> C Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: