in Programming in C edited by
22,276 views
42 votes
42 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
in Programming in C edited by
22.3k views

3 Comments

1
1
A
0
0
So Lets take an example of aliasing :

int a = 10 ;

int *p = &a ;

int *q = &a ;

Now pointers p and q are referencing to the same object a .

Hence a is aliased , in simple terms it means that the memory location of a can be accessed using different names p and q .
0
0

9 Answers

48 votes
48 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.

edited by

4 Comments

In sql aliasing means temporarily rename a table.same concept in c ?
2
2

@MRINMOY_HALDER

is sql a programming language as mentioned in the question?

0
0

 

there is no programing language mentioned in the question.

0
0

For instance, if a function takes two pointers A and B which have the same value, then the name A aliases the name B.

Can you give a code snippet for the above statement as it will make it more clear .

0
0
41 votes
41 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=a*a;

A)multiple variables having the same memory location

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

This example also good http://www.cs.uregina.ca/Links/class-info/cplusplus/Standards/Disk10/aliasing_c.html

4 Comments

@Soumya

actually variable and identifier refers to same in C programming

right?
1
1
you are right.
0
0

@srestha the link that you have given, in there, there is the stmt. “ /* call SomeFunction with the Global Variable as a parameter */ ”. how can a global variable be defined inside the main function? Is it a typo?

0
0
16 votes
16 votes
A OPTION
by

4 Comments

Call by reference is the best example for that.

3
3
we can relate to SQL query also...

SQL aliases are used to give a table, or a column in a table, a temporary name.
3
3
C Programming Language does not allow call by reference.
0
0

@akash.dinkar12

is sql a programming language as mentioned in the question? SQL (Structured Query Language) is a database management language for relational databases. SQL itself is not a programming language.

Though for argument's shake one may include it as programming language which maybe valid, but the spirit of the question is against it.

0
0
3 votes
3 votes
int i=10;
int *p=&i;
As long as p points to i,  we say that *p is an alias for i.

2 Comments

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.
0
0

@Sambhrant Maurya

yes and for Option A to be true by this argument, variables here are

1. i

2. p

only. And clearly,

" multiple variables having the same memory location " (option A)

is not the case here. Though the, memory location

&i can be accessed by two ways :
&i and *p.

Logic of UNION gives OPTION A. Not this argument

 

0
0
Answer:

Related questions