vendredi 19 juillet 2019

integer function with no return value [duplicate]

I'm trying to execute the below code, since the function has no return value but it was defined with integer return type. how it was running without any error.

#include <stdio.h>
int fn(int a, int b){
  int temp = b;
  a = 2*temp;
  b = a;
}
int main()
{
  int x,y,printval;
  scanf("%d%d",&x,&y);
  printval = fn(x,y);
  printf("%d", printval);
  return 0;
}

i Expect the output be error but it was resulting in 40(input:10,20)

Aucun commentaire:

Enregistrer un commentaire