Skip to content
Official PYQ · 2000

GATE CS 2000 Q1.16 — Programming in C

Explain with AI

Aliasing in the context of programming languages refers to

Choose one option
View worked solution

Answer: A

In programming languages, aliasing refers to a situation where a single memory location can be accessed through different symbolic names (variables or identifiers) in the program.

When two or more variables are aliases for the same memory location, modifying the value through one variable automatically updates the value accessed by the other variable. This can lead to side effects that make program analysis and optimization challenging for compilers.

Examples of Aliasing:

  • Pointers in C/C++:
    If we have int x = 5; int *p = &x;, then both x and *p refer to the same memory location.
  • References in C++:
    If we define int &y = x;, then y is an alias for x.
  • Unions in C:
    Members of a union share the same memory space.

Evaluating the Options:

  • A. Multiple variables having the same memory location: This is the correct definition of aliasing.
  • B. Multiple variables having the same value: This simply means the variables are equal in value (e.g., a = 5; b = 5;), but they occupy distinct memory locations.
  • C. Multiple variables having the same identifier: This is generally invalid in the same scope, or refers to scope shadowing, not aliasing.
  • D. Multiple uses of the same variable: This is just standard variable usage.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Programming in C questions