All articles
c

A program to explain FUNCTION WITHOUT ARGUMENTS and WITHOUT RETURN VALUES

Share this article

Share on LinkedIn Share on X (formerly Twitter)

C Programming Language 075

  • Write a program to explain FUNCTION WITHOUT ARGUMENTS and WITHOUT RETURN VALUES

Program

#include <stdio.h>
 
void triangle();
 
void main()
{
    triangle();
    printf("\n");
}
 
void triangle()
{
    float a, b, h;
    printf("Enter b, h: ");
    scanf("%f %f", &b, &h);
 
    a = 0.5 * b * h;
    printf("Area = %f", a);
}

Result

Enter b, h: 2 3
Area = 3.000000

Comments