Can you please tell me what I did wrong with this code?
Code:
#include <stdio.h>
int min(int x, int y);
int main(){
int x;
int y;
int minimum;
printf("les inn x: ");
scanf("%d" , &x);
printf("les inn y: ");
scanf("%d" , &y);
minimum=min(x, y);
printf("%d er det minste tallet\n" , minimum);
return 0;
}
int min(){
int minimum;
int x;
int y;
if (x<=y){
minimum=x;
}
else if (y<=x){
minimum=y;
}
return minimum;
}
Im having a real hard time understanding how functions work.
EDIT: I now see what I did wrong. x and y is not declared to any value in the min function. How can I declare it to get the value from main function? I thought it would happen on its own
EDIT: I see my mistake and fixed the problem