# Wtf is wrong with this code(simple one) ?????

 Alex Carter · April 14, 2015 Here is very simple cod, it doesn't have errors, but it doesn't work.#include void izFuC(int f, double c) { c = (f - 32) * 5/9;}int main(void) { int f=89; double c=0; izFuC(f, c); printf("F=%d pretvoreno u C=%lf",f,c); return 0;}

## Replies

 Dol Lod · April 15, 2015 You are not modifying c by reference so all changes made will be local to the function.To fix this 1) Simple solution is have c=izFuC(f,c) to set the value of c after the function call.2) A more advanced solution is to pass in a pointer to c and do *c=(f-32)*5/9void izFuC)int f, double* c){  *c=(f-32)*5/9}You get the address of a variable by using &. c student · April 15, 2015 make the return type of izFuC a double and return it``double izFuC (int f, double c) { return (f - 32) * 5/9;}int main (void) { /* your code here */ printf("F=%d pretvoreno u C=%lf",f, izFuC (f, c)); return 0;}``you can return it directly into printf(), making a return into a variable a redundant procedure unless you plan to reuse the value.
• 1

## C

126,560 followers
About

One of the most popular languages of all time.

Links
Moderators
 Bucky Roberts Administrator