Chapter - 6: Functions And Pointers

Given three variables x, y, z write a function to circularly shift their values to right. In other words if x = 5, y = 8, z = 10 after circular shift y = 5, z = 8, x =10 after circular shift y = 5, z = 8 and x = 10. Call the function with variables a, b, c to circularly shift values.


G
Sections
9
Exercises

A

B

C

D

E

F

G

1

2

3

4

5

6

7

8

9

10

11

12

#include<stdio.h>
#include<conio.h>

void chng(int*, int*, int*);

int main()
{
	int a, b, c;
	printf("Enter three numbers : ");
	scanf("%d%d%d", &a, &b, &c);

	printf("\n\nYou've Entered\n\na : %d	b : %d	c : %d\n", a, b, c);
	chng(&a, &b, &c);

	printf("\nAfter Shifting\n\na : %d	b : %d	c : %d\n", a, b, c);
	getch();
	return 0;

}
void chng(int *a, int *b, int *c)
{
	int x;
	x = *c;
	*c = *b;
	*b = *a;
	*a = x;
}

© 2020 Garbage Valuegarbage value logo