answersLogoWhite

0


Best Answer

Depends on the programming language you are using. I will give two simple examples.

In Command Prompt and when creating a batch file, you declare a variable by entering the "set" command. You can use different switches to change the type of variable you are declaring.

/p makes the variable able to accept user input.

/a makes the variable a numerical expression.

In Python, you declare a variable just by stating the name of the variable and its value.

x = value.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you declare variables and constants.explain with example?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Computer Science

What is forward reference in one pass assembler?

When one pass assembler constructing the object code, if it finds usage of the variables before the declaration then forward reference problem will occur. To avoid forward reference problem: i) Declare the symbols before using it ii) Use more than one pass assembler(multi pass assembler)


What is the principles of digital terrain modelling?

The principles of digital terrain modelling include elevation and local topographic variables. It also includes regional topographic variables as well as structural lines.


When using post method in php whether the variable displayed in url?

No, the variables do not form part of the URL visible in the address bar. They only display in GET methods or manually appended.To access POST variables in scripts, you need to use $_POST['variable_name'];


What is the difference between numeric and string variables?

Numeric variables store numbers for doing mathematics, counting etc.. String variables store printable sets of characters that can be read by humans in what ever language. int i=3; /* a numeric variable in c */ char *hello = "Hello world, Im 3 years old" /* string that contains a number */ Computer languages generally provide many different ways to transform one into the other.


What is the meaning of constant variables?

Constant variables are variables that, once initialized, do not change in value. They are effectively the same as literal constants, except that you can use symbolic names to make it easier to understand the meaning of the program. For instance, in a trigonometry program, it is easier to use the identifier PI than it is to use the literal 3.1415926535897932. Also, if you have a constant that might be adjustable, such as a factor in an equation, naming it allows you to change its value by changing only one line of code, rather than seeking out all of the lines of code that refer to the factor. Constant variables are also candidates for being placed in read-only memory, potentially making the program more secure.

Related questions

Can a pointer be considered a variable?

You can declare pointer-variables, if that's what you mean. Example: char *sample = "Sample";


Does HTML allow you to declare integer real string and boolean variables?

HTML is not a programming language and as such does not allow you to declare variables.


What do you mean by implicit and explicit variables declaration in visual basic?

implicit means you must declare variables before using them while explicit is not a must you declare variables before using them


whose variables are also known as global variables?

The variables which are declared outside the main() function is known as global variables and they can be used anywhere in the program. And, the variables which used declare inside the main() function is known as local variables and they can be used inside the main() function only. Example: #include<stdio.h> #include<conio.h> int x,y; // global variables void main() { int a,b; // Local variables ------------ ---------------------- --------------------- getch(); }


What is used to declare variables in Visual Basic?

declaration of variable is dim a as integer


How many structure variables of a given type can you use in a C program?

You can use unlimited number of variables for a structure and you can also declare array of structures.


When do you declare a variable method and a class final?

When There is No Need to Change the Values of the Variables In Entire lifetime of That variables then we must use that Variable as Final Variable.


Why all variables are declared with in the function?

It is not necessary to to declare variables inside the function in C. If you declare a variable inside a function, the variable becomes local for the function and another variable of same name can be declared in any other function, but you can not use the variable declared in other function. When you declare any variable outside the function body then the variable becomes global and can be used in any function of the program. Note: errno is an example for a variable declared outside any function.


How do you teach variables in your classroom?

Variables are introduced as placeholders that can hold different values. I teach students how to declare variables, assign values to them, and use them in mathematical expressions or conditions. We practice using variables in various problem-solving scenarios to reinforce their understanding.


How do you declare many float variables in java?

You can declare them one by one. However, if you want to store lots of related data, you may want to consider using an array, where you use a single variable name (for example) for 1000 different items, and a number called an index to access the individual items.


What is an example of a sentence with the word declare?

I want to declare my business bankrupt.We will declare war on you if you step foot on our ally, Australia.


What is an Example of two independent variables?

Variables are symbols that replace unknown numbers. Variables are often letters. For example: 5*x=10 7*6=y Here "x" and "y" are the variables.