42 votes 42 votes Aliasing in the context of programming languages refers to multiple variables having the same memory location multiple variables having the same value multiple variables having the same identifier multiple uses of the same variable Programming in C gatecse-2000 programming easy aliasing + – Kathleen asked Sep 14, 2014 • edited Oct 26, 2016 by go_editor Kathleen 24.7k views answer comment Share Follow See all 3 Comments See all 3 3 Comments reply Akhilesh Singla commented Apr 18, 2018 reply Follow Share Option A. https://en.wikipedia.org/wiki/Aliasing_(computing) 1 votes 1 votes Gajanan Purud commented Sep 18, 2023 reply Follow Share A 0 votes 0 votes Subham640 commented Mar 17 reply Follow Share 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 . 1 votes 1 votes Please log in or register to add a comment.
Best answer 48 votes 48 votes Option is A. In computer programming, aliasing 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. Prasanna answered Nov 13, 2015 • edited Jun 14, 2018 by Milicevic3306 Prasanna comment Share Follow See all 4 Comments See all 4 4 Comments reply mrinmoyh commented Apr 11, 2019 reply Follow Share In sql aliasing means temporarily rename a table.same concept in c ? 2 votes 2 votes Bhartendu Kumar commented Jul 8, 2020 reply Follow Share @MRINMOY_HALDER is sql a programming language as mentioned in the question? 0 votes 0 votes manish_pal_sunny commented Aug 11, 2020 reply Follow Share Bhartendu Kumar there is no programing language mentioned in the question. 0 votes 0 votes jatinsharma437 commented Nov 3, 2020 reply Follow Share 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 . 1 votes 1 votes Please log in or register to add a comment.
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 srestha answered Jan 1, 2017 srestha comment Share Follow See all 19 Comments See all 19 19 Comments reply Swati Rauniyar commented Aug 25, 2017 reply Follow Share @srestha Is your example for option (C) allowed in code? 1 votes 1 votes srestha commented Aug 25, 2017 reply Follow Share why will it not allow? 0 votes 0 votes Swati Rauniyar commented Aug 26, 2017 reply Follow Share Try running this code- http://ide.geeksforgeeks.org/ccAyN2 1 votes 1 votes srestha commented Aug 26, 2017 reply Follow Share yes, it is giving error because C doesnot allow multiple variable with same name it is the example, what option C) is telling 1 votes 1 votes Swati Rauniyar commented Aug 26, 2017 reply Follow Share As far as I know option (C) can't be implemented in real. Correct me if I am wrong. 0 votes 0 votes Soumya29 commented May 30, 2018 reply Follow Share Two pointers pointing to the same memory location is a good example of aliasing. Can we relate aliasing with the union? 1 votes 1 votes Soumya29 commented May 30, 2018 reply Follow Share Example of multiple variables having the same identifier - void fun1() { int t =10; // local variable of function fun1. printf("%d",t); } void fun2() { int t=11; // local variable of function fun2. t= t+t; printf("%d",t); } int main() { fun1(); fun2(); return 0; } 5 votes 5 votes srestha commented May 30, 2018 reply Follow Share @Soumya Can we define a pointer as a variable? In question they are asking just for a variable and not pointer https://stackoverflow.com/questions/17643036/whats-the-difference-between-a-pointer-and-a-pointer-variable 2 votes 2 votes Soumya29 commented May 30, 2018 reply Follow Share @Srestha..Yes, we can define. Pointer is just a variable that can hold address of another variable. 4 votes 4 votes srestha commented Jun 23, 2018 reply Follow Share @Soumya 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 right? 0 votes 0 votes srestha commented Jun 23, 2018 reply Follow Share 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 0 votes 0 votes Soumya29 commented Jun 23, 2018 reply Follow Share @Srestha. 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? 4 votes 4 votes srestha commented Jun 23, 2018 reply Follow Share do u mean union always operate on the concept of aliasing? That is not true I think 0 votes 0 votes Soumya29 commented Jun 23, 2018 reply Follow Share @srestha . Any counter example ? 0 votes 0 votes srestha commented Jun 23, 2018 reply Follow Share See here https://www.foss-sthlm.se/mail/foss-sthlm-archive-2013-06/att-0024/FOSS-juni-2013-aliasing.pdf it is saying in union , aliasing is bug for sometime 1 votes 1 votes Mk Utkarsh commented Jun 24, 2018 reply Follow Share 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. 0 votes 0 votes srestha commented Aug 7, 2018 reply Follow Share @Soumya actually variable and identifier refers to same in C programming right? 1 votes 1 votes manikantsharma commented Jul 8, 2022 reply Follow Share you are right. 0 votes 0 votes Rajsukh Mohanty commented Nov 11, 2023 reply Follow Share @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 votes 0 votes Please log in or register to add a comment.
16 votes 16 votes A OPTION _xor_ answered May 21, 2015 _xor_ comment Share Follow See all 4 Comments See all 4 4 Comments reply Anu007 commented Dec 4, 2017 reply Follow Share Call by reference is the best example for that. 3 votes 3 votes akash.dinkar12 commented Dec 19, 2017 reply Follow Share 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 votes 3 votes prithatiti commented Jan 9, 2020 reply Follow Share C Programming Language does not allow call by reference. 0 votes 0 votes Bhartendu Kumar commented Jul 8, 2020 reply Follow Share @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 votes 0 votes Please log in or register to add a comment.
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. Aakash_ answered Jul 9, 2018 Aakash_ comment Share Follow See all 2 Comments See all 2 2 Comments reply Sambhrant Maurya commented Jan 16, 2019 reply Follow Share 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 votes 0 votes Bhartendu Kumar commented Jul 8, 2020 reply Follow Share @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 votes 0 votes Please log in or register to add a comment.