we all know that "1" is stored in somewhere in the memory, which will take the space of a int type.
And we all know, when we are using variable A, the cpu will find the location of A and get the value of it.
However, my question is:
computers=CPU+Memory, then if CPU does the calculation then memory have to store all information.
How could cpu knows where to look for the value of A?
There must be some place stored the memory location information of A, then where is that information located? How much memory space it takes? and how to fetch that information? Another location...??? never ending forever?
Depends on the type and size of the literal. 192 will probably be stored as part of a machine instruction, but "Hello, World!\n" does need to have memory set aside for it.
Larger literals like 3.141592f or 2404515840 may also need to be stored at distinct addresses.
EDIT: It also depends on what kind of operation you're performing. Whether the compiler decides to optimize some aspect of your program away also matters.
Not necessarily. Imagine a hypothetical embedded device where code resides in a ROM chip in a separate address space. It's also memory (from the point of view of a Von Neumann architecture), but it's a kind of memory that a C program can't read, write, or even be aware of.
It's also memory
My point. that a C program can't read, write, or even be aware of.
If this hypothetical device is explicitly built like this.
The microcontrollers I'm aware of allow me to read everywhere.
I was mainly reacting to A literary constant is not stored in memory, right?
which is imho outright wrong.
Well, the C abstract machine makes a clear distinction between memory for code and memory for data.
"Memory" without any qualifiers refers to data memory, so I think OP was asking whether a literal is stored in data memory in the general case.
Whether some specific implementations combine both types of memory into one is irrelevant, in my opinion.