plz solve ...

int main()
{
    const int m=10;
    int &n=m;
    n=11;
    printf("%d%d",m,n);
}

can w declare &n...its not an error...

Are you using a C compiler, or a C++ compiler?

In C++, &n would be a reference to n. I'm unsure how a C++ compiler would handle that reference, in a declaration.

In C, a declaration of &n is an error. These are the errors I get from my Pelles C compiler:

C:\Users\adak\Documents\Pelles C Projects\sortingX\sortingX.c(11): error #2014: Empty declaration.
C:\Users\adak\Documents\Pelles C Projects\sortingX\sortingX.c(11): error #2001: Syntax error: expected ';' but found '&'.
C:\Users\adak\Documents\Pelles C Projects\sortingX\sortingX.c(11): error #2048: Undeclared identifier 'n'.
C:\Users\adak\Documents\Pelles C Projects\sortingX\sortingX.c(11): error #2168: Operands of '=' have incompatible types 'int *' and 'int'.
C:\Users\adak\Documents\Pelles C Projects\sortingX\sortingX.c(11): error #2088: Lvalue required.
*** Error code: 1 ***

I compile this code on gcc compiler and get this error

error: lvalue required as left operand of assignment

When you use & before a variable you are pointing to the variable address not the content of that so when you declare &n =m it seems meaningless because you are saying that the address of the n should be the same as the content of the m that maybe change rapidly.

&n is a reference variable. We can't use ref variables in C. However, it can be used in C++.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.