Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Strange results from the C program

KotikKotik Posts: 7Member
Hello, I am getting up to speed with C during the week and I have written one of my first programs and I do not understand why the return of the function. If I input X as 3, Y as 4 and N as 6 I get the return as several million. I should be getting the return of check funtion as 1 with those inputs.

#include

int check(int x,int y,int n);

int main(void)
{
int x,y,n;
printf("
Value of X: ");
scanf("%d", &x);

printf("
Value of Y: ");
scanf("%d", &y);

printf("
Value of N: ");
scanf("%d", &n);

check(x,y,n);
printf("check = %d", check);
if (check == 1){
printf("vx and y checked out.");
}
else if (check == 0){
printf("Digits failed the check");
}
}

int check(int x,int y,int n)
{
int i=0;
if (x>0 && x<(n-1)){
if (y>0 && y<(n-1)){
return 1;
}
}

}

Sign In or Register to comment.