# Given an array p, write a function to shift it circularly left by two positions. Thus, if p = 15, p= 30, p = 28, p= 19 and p = 61 then after the shift p = 28, p = 19, p = 61, p = 15 and p = 30. Call this function for a (4 x 5 ) matrix and get its rows left shifted.

L
Sections
11
Exercises

A

B

C

D

E

F

G

H

I

J

K

L

1

2

3

4

5

6

7

8

9

10

11

13

14

15

16

17

18

19

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

void shift(int *base)
{
int *web, fir, sec, i;
web = base;
fir = *base;//saving first value in fir variable
sec = *(base + 1);//saving second value insec variable

for (i = 0; i<3; i++)//shifting the values by saving them in next to next addresses
*(web + i) = *((base + 2) + i);

*(web + 3) = fir;
*(web + 4) = sec;
}

int main()
{
int a, i;

printf("Enter 5 numbers : ");
for (i = 0; i<5; i++)//scanning values
scanf("%d", &a[i]);

shift(a);//calling function

printf("\n\nList after shifting it's rows by two positions.\n\n");
for (i = 0; i<5; i++)//printing values after shifting

printf("%d ", a[i]);
_getch();
return 0;
}``````

© 2020 Garbage Value 