The purpose of an algorithm

Algorithms are really intended as a blueprint for communication to programmers.

Example: Finding the area of a circle

Problem Definition: A solution is needed to find the area of a circle given a radius.

Solution as a flowchart

Solution in pseudocode:

//variable declaration
float radius
float area
float pi  = 3.14

print "Please enter a radius"
input radius

area = pi * radius * radius

print "The area is : ", area


Actual program code in C:

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

int main()
    float radius, area;
    const float pi = 3.14;
    printf ("Please enter a radius\n");
    scanf("%f", &radius);

    area = pi *radius *radius;
    printf ("\nThe area is : %f", area);

    return 0;

Notice how similar the pseudocode is to the actual coded solution.

© 2022  Vedesh Kungebeharry. All rights reserved. 

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s