Home  |  IT Zone  |  Tips / Tricks  |  Did You Know  |  Inspirational  |  Health  |  World Infos  |  Insurance  |  Universities  |  Forex  |  Mathematics  |  Illusions  |  Children Day Quotes  |  Fun / Jokes  |  Decent Quotes  |  Birthday Msgs  |  Good Morning Msgs  |  Good Night Msg  |  Husband Wife Jokes  |  Teacher Students Jokes  |  Insult Jokes  |  Love Quotes  |  Sad Quotes  |  Funny Pics  |  Be Aware  |  Articles  |  Simple Joys of Life 

What is constant?

  • In programming, a constant is a value that never changes. It is a location in computer memory that gets the value before execution of the program and that can be used in the program.
    • Example:  
    • 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.
  • A constant may be a character, text or number which can hold any data and which has value assigned before the execution of program.

Share :

X
Back To Top

facebook main

Powered by Blogger.