void data type in c

Void is an empty data type that has no value. We use void data type in functions when we don’t want to return any value to the calling function or When used for a function’s parameter list: void specifies that the function takes no parameters.

ex;

void sum(int a, int b)

{

int sum=a+b;

printf(“%d”,sum);

}

ex 2:

int sum(void)

 {

      int a,b;

      printf(“Enter Two number “);

      scanf(“%d%d”,&a,&b);

      return a+b;

 }

Basically void is a keyword to use as a placeholder where you would put a data type, to represent “no data”.

Leave a Comment