0% found this document useful (0 votes)
77 views

Computer Programming (Assignment - VIII) : Pointers

This document contains 6 programming assignments related to pointers in C: 1. The first assignment asks for the output of 6 code snippets using pointers and addresses. 2. The second assignment asks for a program to print the size of different pointer variable types. 3. The third asks for a program to add two numbers using pointers. 4. The fourth asks for a program to print a string using a pointer. 5. The fifth asks for a program to read and print array elements with their addresses using a pointer. 6. The sixth asks for a program demonstrating a double pointer (pointer to a pointer).

Uploaded by

Pranshu Dixit
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)
77 views

Computer Programming (Assignment - VIII) : Pointers

This document contains 6 programming assignments related to pointers in C: 1. The first assignment asks for the output of 6 code snippets using pointers and addresses. 2. The second assignment asks for a program to print the size of different pointer variable types. 3. The third asks for a program to add two numbers using pointers. 4. The fourth asks for a program to print a string using a pointer. 5. The fifth asks for a program to read and print array elements with their addresses using a pointer. 6. The sixth asks for a program demonstrating a double pointer (pointer to a pointer).

Uploaded by

Pranshu Dixit
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/ 2

Computer Programming (Assignment - VIII): Pointers

1. What would be the output of the following programs:-


a) b)
#include<stdio.h>
main( ) #include<stdio.h>
{ main( )
int a = 5,b = 10,c ; {
int *p = &a ,*q = &b; int i=3, *j, k;
c=p–q; j = &i ;
printf("%d" , c) ; printf("%d\n", i**j*i+*j) ;
} }

c) d)
#include<stdio.h>
main() #include<stdio.h>
{ main()
int x=30, *y, *z ; {
y= &x ; int ***r, **q, *p, i=8 ;
/* Assume address of x is 500 and integer is 4 byte p = &i ;
size */ q = &p ;
r = &q ;
z = y; printf("%d, %d, %d\n", *p, **q, ***r);
*y++ = *z++ ; }
x++ ;
printf("x=%d, y=%d, z=%d\n", x, y, z);
}

e) f)
#include<stdio.h> #include<stdio.h>
main( ) main()
{ {
float a = 13.5 ; int i = 5 , j ;
float *b, *c ; int *p , *q ;
b = &a ; /* suppose address of a is 1006 */ p = &i ;
c=b; q = &j ;
printf ( "\n%u %u %u", &a, b, c ) ; j=5;
printf ( "\n%f %f %f %f %f", a, *(&a), *&a, *b, *c ) ; printf("%d %d", *p,*q) ;
} }

1
2. C program to print size of different types of pointer variables.

Hint:- Output depends on the system architecture, but each type of pointer will take
same memory space.

3. C program to add two numbers using pointers.

4. C program to print a string using pointer.

5. Program to read array elements and print with addresses using pointer.

6. C program to demonstrate example of double pointer (pointer to pointer).

You might also like