Introduction to functions


Required reading: C functions (This is a link to an external website)


Similar to our previous example, create a program which contains:

  1. A function which returns the area of a circle given its radius (assume all variables used are double)
  2. A Function which returns the volume of a circle given the radius(assume all variables used are double)
  3. A function which does not return any data and takes no parameters but outputs the author of your program .  Name your function Signature.


Note the function declarations.  This is necessary for proper execution of our code.

#include <stdio.h>
#include <stdlib.h>

//global variables
double area,volume;
double radius;
const double PI = 3.14;

//function declarations
double Area(double radius);
double Volume(double radius);
void Signature();

int main()
    area,radius,volume = -999;

    printf("enter radius\n");
    scanf("%lf", &radius);

    area    =   Area(radius);
    volume  =   Volume(radius);

    printf("The  Area is \t: \t%.2f\n",area);
    printf("The  Volume is \t: \t%.2f\n",volume);



double Volume(double radius)

double Area(double radius)
    return (PI*radius*radius);

void Signature()
	//ASCII Art Generated using
    printf("Thanks for using my program!  \n");
    printf("  _  __                       \n");
    printf(" | |/ /                       \n");
    printf(" | ' /_   _ _ __   __ _  ___  \n");
    printf(" |  <| | | | '_ \ / _` |/ _ \ \n");
    printf(" | . \.|_| | | | | (_| |  __/ \n");
    printf(" |_|\_\__,_|_| |_|\__, |\___| \n");
    printf("                   __/ |      \n");
    printf("                  |___/       \n");
    printf("Author: Vedesh Kungebeharry   \n");
    printf("contact:     \n");
    printf("exiting...  \n");


© 2020  Vedesh Kungebeharry. All rights reserved. 

Formulas and Functions – Part 2 (Video)

This series of videos is a continuation of the post, Formulas and Functions – Part 1 (Class Video)

Use this file and follow along with the videos, pausing the video when you need to accomplish a task:

It 5 videos covering the following functions: Max, Min, Count, Countif, Rank, and Vlookup.

A 6th function, PMT was left for your research and homework.

See the videos below, and follow the instructions for homework based on the pmt function:

Max and Min






Homework – Research/examine the PMT function.

Explain :

  1. The functions’ parameters.
  2. The purpose of the function.

We will be discussing this function at our next class.

© 2020  Vedesh Kungebeharry. All rights reserved.