Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Tuesday, March 10, 2015

What is void ?

It is also a data type that has no values. In other word it is a null data type. The void is mainly used for non-return type functions.
It is also a keyword and primary or inbuilt data type. It is also play the role of generic type meaning that it can represent any of the other standard types.
Syntax:
     void Function_name();
Ex:
     void calculate();

program: Create a non-return type function to add two number.
#include<stdio.h>
#include<conio.h.>
void calculate(int x, int y); //non-return type function with
//two arguments
void main() // non-return type main() function
{
     int a, b;
     printf(“Enter Two Values : “);
     scanf(“%d%d”, &a, &b);
     calculate(a,b); //calling calculate function
     getch();
}
void calculate(int x, int y)
{
     int sum;
     sum = x + y;
     printf(“Sum = %d”, sum);
}

Output:
     Enter Two Values : 20 15

     Sum = 35

No comments:

Post a Comment