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

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

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.