Write the function rotateLeft which shifts each element in the array left by one position, moving the first element to the end. Return the modified array. arrays.cpp 1 #include // size t 2 3 int* rotateleft(int a[], size t len) { 4 6. return a; 9. } Tester.cpp 1 #include 2 using namespace std; 3 #include "arrays.h" int main() { int al[] = {10,13,14,10,10,8}; auto len1 = sizeof(al) / sizeof(al[0]); print ("before al->", al, len1); print("after al: ", rotateLeft(al, len1), len1); cout « "Expected: [13, 14, 10, 10, 8, 10]" « endl; cout « endl; 4 5 7 8 9. 10 11 12 13 int a2[] = {3,9,9,5}; auto len2 = sizeof(a2) / sizeof(a2[0]); print("before a2->", a2, len2); print("after a2: ", rotateLeft(a2, len2), len2); cout « "Expected: [9, 9, 5, 3]" « endl; } 14 15 16 17 18 19 CodeCheck Reset
Write the function rotateLeft which shifts each element in the array left by one position, moving the first element to the end. Return the modified array. arrays.cpp 1 #include // size t 2 3 int* rotateleft(int a[], size t len) { 4 6. return a; 9. } Tester.cpp 1 #include 2 using namespace std; 3 #include "arrays.h" int main() { int al[] = {10,13,14,10,10,8}; auto len1 = sizeof(al) / sizeof(al[0]); print ("before al->", al, len1); print("after al: ", rotateLeft(al, len1), len1); cout « "Expected: [13, 14, 10, 10, 8, 10]" « endl; cout « endl; 4 5 7 8 9. 10 11 12 13 int a2[] = {3,9,9,5}; auto len2 = sizeof(a2) / sizeof(a2[0]); print("before a2->", a2, len2); print("after a2: ", rotateLeft(a2, len2), len2); cout « "Expected: [9, 9, 5, 3]" « endl; } 14 15 16 17 18 19 CodeCheck Reset
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter12: Points, Classes, Virtual Functions And Abstract Classes
Section: Chapter Questions
Problem 29SA
Related questions
Question
C++
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr