#include<stdio.h>
int add(int, int); // function prototype
int main()
{
int a, b;
// printf("Enter 2 integer numbers\n");
// scanf("%d%d", &a, &b);
//function call add(a, b);
printf(" %d %d = %d \n", a, b, add(2, 7));
Please focus on this line why it gives address 0 = 9//
return 0;
}
//function definition
int add(int x, int y)
{
return x y;
}
// produces outPut : 199164000 0 = 9
CodePudding user response:
You commented the scanf function and also didn't given values for the a and b. So it printed garbage values. You also need to pass a and b into the add(a,b) function.
#include<stdio.h>
int add(int, int); // function prototype
int main()
{
int a, b;
// printf("Enter 2 integer numbers\n");
scanf("%d%d", &a, &b);
//function call add(a, b);
printf(" %d %d = %d \n", a, b, add(a, b));
return 0;
}
//function definition
int add(int x, int y)
{
return x y;
}
CodePudding user response:
It is not printing any address. It is printing garbage values. You have not given any values to the variable a and b. So it will print garbage values. Why you commented scanf statement. Just stop commenting it and it will work.