Example (constant and variable)

A program to find the circumference of a circle. (Qbasic code)
CLS
INPUT "Enter the radius of circle"; r
pi = 3.14
c = 2 * pi * r
PRINT "The circumference of the circle is "; c
END

  • In the given program,
    • the value of  'r' is not fixed. Its value can be changed according to the user. So, 'r' is variable.
    • the value of 'pi' is already given so its value is fixed. And it remains same in the entire program. So, 'pi' is constant.

Share :

Twitter
Back To Top

facebook main

counter

Powered by Blogger.