The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+18 votes

Aliasing in the context of programming languages refers to

  1. multiple variables having the same memory location
  2. multiple variables having the same value
  3. multiple variables having the same identifier
  4. multiple uses of the same variable
asked in Programming by Veteran (59.9k points)
edited by | 2.3k views

5 Answers

+21 votes
Best answer

Option is A.

In computer programmingaliasing refers to the situation where the same memory location can be accessed using different names. For instance, if a function takes two pointers A and B which have the same value, then the name A aliases the name B.

answered by Active (4.9k points)
edited by
In sql aliasing means temporarily rename a table.same concept in c ?
+20 votes

B)multiple variables having the same value

int a=24;
int b=24;
int c=24;

 C)multiple variables having the same identifier

int a=23;
char a='A';

D)multiple uses of the same variable

int a=23;

A)multiple variables having the same memory location

int a=20;
int *p=&a;

This example also good

answered by Veteran (114k points)
@srestha Is your example for option (C) allowed in code?
why will it not allow?

Try running this code-

yes, it is giving error because C doesnot allow multiple variable with same name

it is the example, what option C) is telling
As far as I know option (C) can't be implemented in real. Correct me if I am wrong.
Two pointers pointing to the same memory location is a good example of aliasing.

Can we relate aliasing with the union?

Example of multiple variables having the same identifier -

void fun1()
int t =10;  // local variable of function fun1.

void fun2()
int t=11;  // local variable of function fun2.
t= t+t;

int main()
return 0;


Can we define a pointer as a variable?

In question they are asking just for a variable and not pointer

@Srestha..Yes, we can define. Pointer is just a variable that can hold address of another variable.

why r u relating union here?

"A union is a variable that may hold (at different times) objects of different types and sizes,"

but union is not about same memory location


do u mean. in union for a highest memory location , a memory will be created,

but in structure,we need to create memory for every variable

like told here


Aliasing describes a situation in which a data location in memory can be accessed through different symbolic names in the program.
Now I meant to say that-
Consider this union.

union { 
        float y; 
        long z; 
    } u;

Here 8 Bytes of memory will be allocated for it. Say from 1000 to 1008.
Now we can access this memory location using &u.y and &u.z.

So can we say it aliasing?

do u mean union always operate on the concept of aliasing?

That is not true I think
@srestha . Any counter example ?
i think union always operate on the concept of aliasing just the issue is that obviously we cannot access the value assigned to the variable by some other variable with distinct data type.

actually variable and identifier refers to same in C programming

+15 votes
answered by (473 points)

Call by reference is the best example for that.

we can relate to SQL query also...

SQL aliases are used to give a table, or a column in a table, a temporary name.
+1 vote
int i=10;
int *p=&i;
As long as p points to i,  we say that *p is an alias for i.
answered by Active (2.9k points)
You sure? Because if i has a memory location 100 then p will point to i but p can have a different memory location, say 200.
–5 votes
ans c)
answered by Loyal (5.2k points)
Option a is more appropriate.

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
49,427 questions
53,611 answers
70,885 users