0% found this document useful (0 votes)
4 views4 pages

Paras Edited

Uploaded by

jinik81428
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

Paras Edited

Uploaded by

jinik81428
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Experiment No:10

Aim: Program to demonstrate pointers


Program:1) Swapping using pointer
Input:

#include <stdio.h>

void swap(int *x,int *y)


{
int t;
t = *x;
*x = *y;
*y = t;
}

int main()
{
int number1,number2;

printf("Enter value of number1: ");


scanf("%d",&number1);
printf("Enter value of number2: ");
scanf("%d",&number2);

printf("Before Swapping: number 1 is: %d, number 2 is: %d\n",number1,number2);

swap(&number1,&number2);

printf("After Swapping: number 1 is: %d, number 2 is: %d\n",number1,number2);

return 0;
}
Output;
Program:2)Store the address of variable in pointer
Input:

#include <stdio.h>

int main() {
int var = 13;
int *ptr;
ptr = &var;

printf("Value of var: %d\n", var);


printf("Address of var: %p\n", (void*)&var);
printf("Value stored in pointer ptr: %p\n", (void*)ptr);

return 0;
}

Output:

You might also like