C Program To Shift Elements of An Array by n Position

preview_player
Показать описание

Write a C program to shift elements of an array by n positions or rotate the array elements n times.

Example: Expected Input/Output
Input/Output
Enter 5 integer numbers
1
2
3
4
5
Enter the number of positions to shift
1
Enter the direction of shifting …
LEFT: 1 and RIGHT: 0
1
Array after shift operation …
2
3
4
5
1

C Programming Interview / Viva Q&A List

C Programming: Beginner To Advance To Expert
Рекомендации по теме
Комментарии
Автор

naturally born a TUTOR. thank you for your generous explanation. Can you put a video about random integers but unique, thank you

naboulsikhalid
Автор

Got the idea for this once I watched your video. Great work!

jtingsoo
Автор

One question though:

I understand why the temp variable is necessary and how it works to preserve the last (or first depending on the direction being shifted) element of the array, but I don't understand if the array was being shifted over by 2 or 3 elements, how does this loop work to preserve those extra values?

Calam
Автор

thankyou for the explanation at 11:00 explaining that while (pos) is the same as while (pos > 0 ).

I am enjoying your videos as supplementary to the cs50 Harvard course. Great course but they lack all these skill drills.

Calam
Автор

You should do this type of explanations on the white board.

bjorn