Computer Science, asked by ccj9369, 8 months ago

what diffrence between '/ ' operator and '//' operator ​

Answers

Answered by rupamkumarisharmaa
1

Answer:

In the context of C (and C++), these operators are related to addresses.

Every variable (and function) has an address. C allows a type of variable called a pointer, which is used to store such addresses. The declaration is as follows.

int *ptr; // Pointer to int

int a; // Normal int

There is a different pointer for each type, like char *, float *, double * etc. The * is used while declaration to declare the type as a pointer to the corresponding type, like char, float, double, etc.

Now, to actually get the address of a variable, you prefix the & operator. Like so

ptr = &a;

This returns the address of a, and assigns it to ptr.

Just having the address is not very useful. You might want to access values at that address. The * operator is used for that too. Prefixing * to a pointer returns the value, like so

int b = *ptr;

Now b contains the current value in the address stored in ptr. As ptr has the address of a, b contains the current value of a. If the value of a changes after this statement, the value of b does not change. Similarly, changing the value of b does not change that of a.

Similar questions