How will you write a function with no arguments and with return value ? Give an example.

Advertisement
Q. How will you write a function with no arguments and with return value ? Give an example.
Ans. #include<stdio.h>
 
void area();  // Prototype Declaration
void main()
{
area();
}
void area()
{
    float area_circle;
    float rad;
    printf("\nEnter the radius : ");
    scanf("%f",&rad);
 
    area_circle = 3.14 * rad * rad ;
 
    printf("Area of Circle = %f",area_circle);
}

Output :


Enter the radius : 3
Area of Circle = 28.260000
Advertisement
Previous
Next Post »
Thanks for your comment