0% found this document useful (0 votes)
26 views

Function With No Arguments and No Return Value in C: Stdio.h

This document discusses functions in C programming with different combinations of arguments and return values. It includes examples of a function with no arguments and no return value, a function with arguments but no return value, and a function with an argument and a return value. The examples calculate the area of a circle using different implementations of functions to demonstrate the concepts.

Uploaded by

saurabh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Function With No Arguments and No Return Value in C: Stdio.h

This document discusses functions in C programming with different combinations of arguments and return values. It includes examples of a function with no arguments and no return value, a function with arguments but no return value, and a function with an argument and a return value. The examples calculate the area of a circle using different implementations of functions to demonstrate the concepts.

Uploaded by

saurabh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Function with no arguments and no Return Value In C

#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);


}

FUNCTION WITH ARGUMENTS AND NO RETURN VALUE :

#include<stdio.h>
#include<conio.h>
//---------------------------------------void area(float rad); // Prototype Declaration
//---------------------------------------void main()
{
float rad;
printf("nEnter the radius : ");
scanf("%f",&rad);
area(rad);
getch();
}
//---------------------------------------void area(float rad)
{
float ar;
ar = 3.14 * rad * rad ;
printf("Area of Circle = %f",ar);
}

Function with argument and return type


#include<stdio.h>
float calarea(int);
int main()
{
int radius;
float area;
printf("\nEnter the radius of the circle : ");
scanf("%d",&radius);
area = calarea(radius);
printf("\nArea of Circle : %f ",area);
return(0);
}
float calarea(int radius)
{
float areaOfCircle;
areaOfCircle = 3.14 * radius * radius;
return(areaOfCircle);
}

You might also like