answersLogoWhite

0

A constant of 5 called MYCONST would be declared as #define MYCONST 5. This is because the statement used is a define statement.

User Avatar

Wiki User

11y ago

What else can I help you with?

Continue Learning about Engineering

How would you write Visual Basic Code to declare an Integer variable called intNumber?

Dim intNumber As Integer


How do you tell your program you are using a VARIABLE?

You have to declare it. The simplest way to do so is by using the Dim keyword. For example if you want a string variable called someString you would declare it thus: Dim someString as string


Which keyword is used to declare constants and variable?

Constants are defines using the final keyword.Variables are defined using the one of the keywords:charbooleanintdoublelongintStringTo use a constant you would have to put in something likedouble final pi = 3.14;


Which access specifier is preferred for constant variables?

There's no such thing as a constant variable (other than as an oxymoron). A named value is either declared constant or it is declared variable, it cannot be both a constant and a variable.You declare a constant much as you would a variable, except you use the final keyword modifier and name the constant using ALL CAPS and underscores for spaces.final int HOURS_IN_DAY = 24;final int DAYS_IN_WEEK;DAYS_IN_WEEK = 7;Note that we don't need to assign a constant value at the point of instantiation. However, once assigned we cannot then change the value. It wouldn't be a constant if we could!The preferred access specifier depends on how useful the constant is. If only one method makes use of the constant, then it should simply be declared within that method as a local constant. If several methods of the same class make use of the constant then declare it a private member of the class. Both methods are used in the following example:public class MyClass {private static int HOURS_IN_DAY = 24;public int hoursInDays (int days) {return days * HOURS_IN_DAY;}public int hoursInWeeks (int weeks) {final int DAYS_IN_WEEK = 7;return weeks * DAYS_IN_WEEK * HOURS_IN_DAY;}}Note the use of the static keyword in the constant declaration. It doesn't make sense for every object of a class to store independent copies of the same constant value, thus we must declare class constants as static members so that all objects of the class can share the same instance of the constant and thus share the same value.If we want the constant to be accessible to our subclasses, then we can declare the constant protected. If we want to make the constant available outside of the class then we can declare it public.Keep in mind that although constants are not variable, we should only expose what needs to be exposed outside of a class, no more and no less. A constant that provides a class implementation detail has no business being accessible outside of the class in which it is declared.You should also be aware that the rules governing constants are different for primitive data types and objects. With primitive data types, the value is constant as one would expect. But with objects, only the reference is constant (we cannot refer to a different object) but if the referenced object allows mutations then it is not truly constant. Unfortunately, the only way to create a truly constant object from a mutable class is to subclass the mutable class and render its setters private.


How do you declare local and global variables in pseudo code?

Pseudocode is not a programming language (it's specifically intended for human interpretation), so there is no need to declare variables, you simply define them as and when you require them. For instance: Let x = 42 Let y = x * 2

Related Questions

What nation was the first to declare war in what would come to be called the Great War?

Austria-Hungary


What branch of government in Rome decides whether or not Rome should go to war with another country?

The senate, by consulting and debate, would declare a war.The senate, by consulting and debate, would declare a war.The senate, by consulting and debate, would declare a war.The senate, by consulting and debate, would declare a war.The senate, by consulting and debate, would declare a war.The senate, by consulting and debate, would declare a war.The senate, by consulting and debate, would declare a war.The senate, by consulting and debate, would declare a war.The senate, by consulting and debate, would declare a war.


What is it called when a state think it has the right to declare a federal law illegal?

That would be a claim of seperation of power.


How would you write Visual Basic Code to declare an Integer variable called intNumber?

Dim intNumber As Integer


Why do you think a variable in an expression is called a variable?

Because it varies, otherwise it would be a constant.


How do you tell your program you are using a VARIABLE?

You have to declare it. The simplest way to do so is by using the Dim keyword. For example if you want a string variable called someString you would declare it thus: Dim someString as string


What is the distance between each number on a graph scale called?

It would normally be called 1unit, though the distance is not a constant.


What is a sentence with the word declare in ti?

I do declare! If you carrying anything across an international border, you would want to declare it to the customs agent.


When did Simón Bolívar declare Brazil's independence?

When Spencer Drake, god of Alberta, told him to declare independence, or he would declare Brazil his own.


If you want to guarantee that the object remains the same after calling a member function on it how would you declare the function?

You would place the const keyword before the function body: class Object { public: Object():m_num(1){} int GetData() const; private: int m_num; }; int Object::GetData() const { return(m_num); } Since GetData() does not alter the instance, it makes sense to declare the function as constant. Note that class instance data members that are declared mutable can still be altered, regardless of constant functions. The use of constant functions only guarantees the non-mutable members cannot be altered.


What is the constant rate of change This is a grade 7 question...?

what is "constant rate of change"I second that.-alixa constant rate of change is the m in Y=MxB In mathematics, a constant rate of change is called a slope. For linear functions, the slope would describe the curve of the function. The world "constant" in this context means the slope and therefore angle of the curve will not change it can also be called a coefficent


Which keyword is used to declare constants and variable?

Constants are defines using the final keyword.Variables are defined using the one of the keywords:charbooleanintdoublelongintStringTo use a constant you would have to put in something likedouble final pi = 3.14;