Hey, I'm writing this report and I'm writing about variables.. I'm just checking to see if this is a good description:


Variables are used in programming to allocate specific memory locations for data, Variables enable the programmer to give a specific name to where the information is stored in memory and then enables the programmer to store and retrieve the information using the given name

Is that.. rubbish or..?

Thanks for any help!

Dani AI

Generated

A crisp, report-ready way to say it (avoiding low-level detail as and suggested):

A variable is a program name that refers to a value of a particular type. The name lets the program store, read, and change that value while the program runs.

A slightly more C++-specific expansion for a technical audience: in C++, a variable is an object with a declared type, a scope (where the name is visible) and a storage duration (how long the object exists — automatic, static, or dynamic). Details about how or where the value is held at runtime (memory, registers, or optimized-away temporaries) are implementation details and not needed for a high-level definition.

Small illustrative C++ declarations:

int count = 0;
const int MAX = 100;
std::string name;

Report-writing tips: use the beginner one-liner for non-technical readers. For a C++ report add one sentence about type, scope and storage duration. Avoid stating that a variable “allocates memory” as a universal rule — that phrasing implies low-level mechanics. The phrasing above keeps the concept correct and useful without getting into compiler or runtime specifics that can confuse beginners.

(Referenced posts: , , .)

Recommended Answers

All 2 Replies

I'd agree with the second sentence. I wouldn't say anything about allocating memory.

Dave

I agree with David (except there's only one sentence :icon_wink:)

The memory aspect actually is more confusing, so don't mention it. It seems immaterial to me in a description unless you are describing the lowest level of programming.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.