C programming language, c++ language, Education, Engineering Course, Java Course

What is void in C? tccicomputercoaching.com

The meaning for the word “void” is “nothing or completely empty”. This term plays a vital role in computerprogramming. The most familiar uses are:

void-c_simple.jpg

  1. Void as a Function Return Type
  2. Void as a Function Parameter
  3. Void as a Pointer Declaration

Examples:

  1. Void as a Function Return Type

void maxval (int a,int b);

void main()

{ int x=6,y=10;

clrscr();

maxval(x,y);

getch();

}

void maxval(int a,int b)

{ if(a>b)

{

printf(“\na=%d is greater value”,a);

}

else

{

printf(“\nb=%d is greater value”,b);

}

}

  1. Void as a Function Parameter

int sum(void); //function declare//

void main()

{ int ans;

clrscr();

ans= sum();

printf(“%d”,ans);

// printf(“ans is %d”, sum()); //function call//

getch();

}

int sum(void)//function defintion//

{

int a,b,c;

printf(“enter the value of a,b”);

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

c=a+b;

return c;

// printf(“\n your addition is=%d”,c);

}

  1. Void as a Pointer Declaration
  2. int main()
  3. {
  4. int a = 10;
  5. void *ptr = &a;
  6. printf(“%d”, *(int *)ptr);
  7. return 0;
  8. }
  9. OUTPUT:
  10. 10

TCCI Computer Coaching teaches various Languages like ,C, C++, Java, Python, Database Management, Python, Data Structure HTML,CSS, Java Script, .Net , PHP, System Programming Compiler Design, Boot Strap, Angular Js etc.

For more information about TCCI in Bopal and Satellite in Ahmedabad.

call us@9825618292.

visit us@tccicomputercoaching.com

 

Leave a comment