পৃষ্ঠাসমূহ

Search Your Article

CS

 

Welcome to GoogleDG – your one-stop destination for free learning resources, guides, and digital tools.

At GoogleDG, we believe that knowledge should be accessible to everyone. Our mission is to provide readers with valuable ebooks, tutorials, and tech-related content that makes learning easier, faster, and more enjoyable.

What We Offer:

  • 📘 Free & Helpful Ebooks – covering education, technology, self-development, and more.

  • 💻 Step-by-Step Tutorials – practical guides on digital tools, apps, and software.

  • 🌐 Tech Updates & Tips – simplified information to keep you informed in the fast-changing digital world.

  • 🎯 Learning Support – resources designed to support students, professionals, and lifelong learners.

    Latest world News 

     

Our Vision

To create a digital knowledge hub where anyone, from beginners to advanced learners, can find trustworthy resources and grow their skills.

Why Choose Us?

✔ Simple explanations of complex topics
✔ 100% free access to resources
✔ Regularly updated content
✔ A community that values knowledge sharing

We are continuously working to expand our content library and provide readers with the most useful and relevant digital learning materials.

📩 If you’d like to connect, share feedback, or suggest topics, feel free to reach us through the Contact page.

Pageviews

Monday, February 6, 2017

Pascal - Constants

A constant is an entity that remains unchanged during program execution. Pascal allows only constants of the following types to be declared −

  • Ordinal types
  • Set types
  • Pointer types (but the only allowed value is Nil).
  • Real types
  • Char
  • String

Declaring Constants

Syntax for declaring constants is as follows −
const
identifier = constant_value;
The following table provides examples of some valid constant declarations −
Constant Type Examples
Ordinal(Integer)type constant valid_age = 21;
Set type constant Vowels = set of (A,E,I,O,U);
Pointer type constant P = NIL;
Real type constant e = 2.7182818;
velocity_light = 3.0E+10;
Character type constant Operator = '+';
String type constant president = 'Johnny Depp';
The following example illustrates the concept −
program const_circle (input,output);
const
PI = 3.141592654;

var
r, d, c : real;   {variable declaration: radius, dia, circumference}

begin
   writeln('Enter the radius of the circle');
   readln(r);
   
   d := 2 * r;
   c :=  PI * d;
   writeln('The circumference of the circle is ',c:7:2);
end.
When the above code is compiled and executed, it produces the following result −
Enter the radius of the circle
23
The circumference of the circle is 144.51
Observe the formatting in the output statement of the program. The variable c is to be formatted with total number of digits 7 and 2 digits after the decimal sign. Pascal allows such output formatting with the numerical variables.

No comments:

Post a Comment