Hello guys, I'm a newbie, and I've started to learn C language about 3 months ago. It's going ok, I'm not super content with my progress, but ok. Anyways, I'm learning from a book Let us C by Yashavant Kanetkar, and I came across a problem where I need a better solution.
***Given an array p[5], write a function to shift it circularly left by two positions. Thus, if p[0] = 15, p[1]= 30, p[2] = 28, p[3]= 19 and p[4] = 61 then after the shift p[0] = 28, p[1] = 19, p[2] = 61, p[3] = 15 and p[4] = 30. Call this function for a (4 x 5 ) matrix and get its rows left shifted.***
My code looks like this. Obviously I haven't done the whole task, only shifted the elements of an array (in the main function). It does its job, but I don't like the code. Nothing comes on my mind when it comes to shifting the first and the second element to an array. Any comment would be helpful! Thank you in advance.
Capture — ImgBB