Question:
What is Variable and what are rules for defining a variable in C/C++.?
hafsa a
2007-03-29 22:55:08 UTC
What is Variable and what are rules for defining a variable in C/C++.
Six answers:
Silver_Sword
2007-03-30 00:18:15 UTC
Variables are like containers or holders of values. If you want to save an integer somewhere you have to assign it to a variable as such:



int someInteger = 4;



Now, here are some rules for defining a variable in C++:



1) The declaration of a variable consists of three parts (the type of the variable, the name of the variable, and the value you are assigning to the variable)



2) The name of the variable can't be a reserved word such as (string, int, double, this, class, main, return, etc.)



3) The value you assign to the variable has to be of the same type as the variable itself. Here are examples:



int a = 7; // this is good

double k = 2.4; // this is good



int c = 5.6; // this is bad because you are assigning a

// double to a variable of type int (integer)
?
2016-12-03 05:28:10 UTC
variable is a knowledge member of this methodology. it have a form meaning the shape of archives it shops (integer huge type, personality etc.) and scope meaning the position that's existed (international or interior of reach). the style is defined interior the line: type ; as an instance: int i; unsigned char letter; the scope is defined by technique of were the line of the statement is placed interior the code. if the definition is exterior the applications that's international variable the this variable is international, if the statement is in a function then the variable is defined purely in this function. in C the statement should be on the starting up of the code executed between the "{" and the code. int C++ it can be everywhere interior the code.
AnalProgrammer
2007-03-30 00:18:18 UTC
The dictionary defines variable as

adjective:-

likely to change frequently:

or

noun [C] SPECIALIZED

a number, amount or situation which can change:



In computing terms a variable is a predefined type of memory allocation that can and probably will change its value.
14Me14U
2007-03-29 23:09:56 UTC
a variable is like a box that contains a specific value,

u can use it or modify it.

there r 2 types of variable : global and local

and there r variables that can be as parameters that enter & leave a specific function.
2007-03-29 23:32:00 UTC
variable is name of a block of memory address
sleepyhead
2007-03-30 01:10:59 UTC
there's a tutorial on www.functionx.com for C/C++


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...