0% found this document useful (0 votes)
7 views7 pages

A37-Assignment 11

Fill

Uploaded by

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

A37-Assignment 11

Fill

Uploaded by

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

Assignment no.

11

1)Initialiize pointer:
#include<stdio.h>

int main()

int i;

float f;

char c;

printf("Enter the integer,float,char:\n");

scanf("%d %f %c",&i,&f,&c);

int *ip=&i;

float *fp=&f;

char *cp=&c;

printf("\n %d",*ip);

printf("\n %f",*fp);

printf("\n %c",*cp);

return 0;

Input:
Enter the integer,float,char:

23

0.99

Output:

23

0.990000

2)pointer to array:
#include<stdio.h>

int main()

int a[5]={23,45,18,33,17},i;

int *p;

p=a;

//p=&a[0];

printf("%u",p);

for(i=0;i<5;i++);

printf("%d",*(p+i));

p++;

return 0;

}
Output: 64875360

3)pointer to structure:
#include<stdio.h>

struct student

int PRN;

char name[10];

int age;

};

int main()

struct student s1={2122000837,"Amey",19};

struct student s2={2122000125,"Prit",17};

struct student *p1,*p2;

p1=&s1;

p2=&s2;

printf("PRN=%d Name=%s Age=%d\n",p1->PRN,p1->name,p1->age);

printf("PRN=%d Name=%s Age=%d\n",p2->PRN,p2->name,p2->age);

return 0;

Output: PRN=2122000837 Name=Amey Age=19

PRN=2122000125 Name=Prit Age=17

4) pointer to function:
#include<stdio.h>

int main()
{

int x,y;

printf("\nEnter x and y value:\n");

scanf("%d %d",&x,&y);

printf("\n Before swap x=%d \t y=%d",x,y);

swap(x,y);

printf("\n After swap x=%d \t y=%d",x,y);

return 0;

void swap(int x, int y)

int temp;

temp=x;

x=y;

y=temp;

printf("\n In swap x=%d \t y=%d",x,y);

Input:

Enter x and y value:

Output:

Before swap x=9 y=2

In swap x=2 y=9

After swap x=9 y=2


5)pointer to string:
#include<stdio.h>

int main()

char a[]={'P','u','s','p','a','r','a','j','\0'},i;

char *p;

//int i;

p=a;

printf("%u\n",p);

for(i=0;i<8;i++)

printf("%c \n",*(p+i));

return 0;

Output: 6487552

j
#include<stdio.h>

int main()

int x,y;

printf("\nEnter x and y value:\n");

scanf("%d %d",&x,&y);

printf("\n Before swap x=%d \t y=%d",x,y);

swap(&x,&y);

printf("\n After swap x=%d \t y=%d",x,y);

return 0;

void swap(int *x, int *y)

int temp;

temp=*x;

*x=*y;

*y=temp;

printf("\n In swap x=%d \t y=%d",*x,*y)

input:

Enter x and y value:

Output:
Before swap x=7 y=0

In swap x=0 y=7

After swap x=0 y=7

You might also like