Pointer:
Pointer is used to points the address of the value stored anywhere in the computer memory. To obtain the value stored at location is known as dereferencing pointer.
Pointer arithmetic:-
4 arithmetic operators that can be used în pointers :++, -, +=Array of pointers:-
You can define array of to hold a number of pointers.
Pointer to pointer :-
C allows you to have pointer on a pointer and so on.
a → 10 → value 2000 => address
b → __ 3000
b=&a → _ 3000 → _ 2000 [b points 4]
Program Pointer →
int main (){
int a = 5;
int *b;
b=&a;
printf ("value of a =%d \n", a);
printf("value of a = %d \n",*(&a));
printf("value of a = "%d \n", *b);
printf("address of a = %u \n", &a);
printf("address of a = "%d \n", b);
printf("address of b = % u\n", &b);
printf("value of b = address of a = %u, b);
return 0;
}
OUTPUT:
Program Pointer to pointer :-
int main (){
int a = 5;
int *b;
int **c;
b = &a;
c = &b;
printf ("value of a = %d\n", a);
printf ("value of b = address of a = %u \n", b);
printf ("value of c = address of b = %u \n", c);
printf("address of b = %u \n", c);
printf("address of c = %u \n", &c);
return 0;
}
OUTPUT:
Structure :-
A structure is a composite data type that defines a grouped list of variables that are to be placed under one name in block of memory.
Program:-
Structure →
struct structure - name.
{
data-type member 1;
data-type member 2;
.
.
.
data-type member ;
};
Advantages of structure :
1. It can hold vanables of different data types.
2. We can create objects containing different types of attributes.
3. It allows us to re-use the electer layout across programs.
4. It is used to implement other data structure like linked list, queues, trees and graphs.
Program :-
how to use structure in program →
void main(){
struct employee
{
int id;
float salary;
int mobile;
};
struct employee e1,e2,e3;
printf("\n Enter ids, salary & mobile. no \n");
scanf("%d %f %d", &e1.id, &e1.salary, &e1.mobile);
scanf("%d %f %d", &e2.id, &e2.salary, &e2.mobile);
scanf("%d %f %d", &e3.id, &e3.salary, &e3.mobile);
printf("\n Entered result ");
printf("\n %d %f %d", e1.id, el.salary, el.mobile);
printf("\n %d %f %d", e2.id, e2.salary, e2.mobile);
printf("\n %d %f %d", e3.id, e3.salary, e3.mobile);
}
OUTPUT:
guess the output And write it here...