GET EDUCATE

Contents
Basics of C Programming

⯈Basic C Programs

Algorithm and Flowchart to calculate area and circumference of circle

Whenever we write an algorithm or program, we always start with reading the input. The input to this algorithm is radius (R) of a circle. 

Formula:

area of circle = ΠR2  , 

circumference of circle = 2ΠR.

Note:

  1. The value of Pi is constant, and constants should not be read as an input.
  2. Read only the values of variables that are part of input.

So, lets read the radius, hence we write Read radius as R

After reading all the necessary inputs it’s the time to calculate the area and circumference. 

a = ΠR2

c = 2ΠR

Then we need to output the results. The results are stored in variables a and c

Note: Variables names are case – sensitive.

Therefore, we write

Display a

Display c

Algorithm:

Name of Algorithm: Compute area and circumference of circle.

Step 1: Start

Step 2: Read radius as R.

Step 3: a = ΠR2

Step 4: c = 2ΠR
 

Step 5: Display [outputs the content stored in variable ‘a’]

Step 6: Display c [outputs the content stored in variable ‘c’]

Sep 7: Stop

Note: We can use mathematical symbols in an algorithm, but cannot be used in programs.

Flowchart:

flowchart area and circumference of circle

Tracing:

Let us do the dry run of the above algorithm:

In step 2, we read the value of radius (R). Let R = 1.5

In step 3 and step 4 we calculate area and circumference and store the result in ‘a’ and ‘c’ respectively.

a =22/7 * 1.52 = 7.071

c = 2 * 22/7 * 1.5 = 9.428

In step 5, and 6, we display the value stored in variable a and c. Therefore we output 7.071 and 9.428

Scroll to Top