Problem 1. Symbol Rotation using Pointer

Write a program that rotates a series of characters in any direction for a given number of times. Your input would be 4 characters for series, 1 character for rotation direction (left/right) and an integer to select the number of rotation. You must take input of the 4 characters for series in pointer type variables. Write one function for rotating the characters to left, another for right. Call the functions from the main function. Your series characters should have new swapped values after the rotation. Print the characters from the main function after you are done with your rotation.

Sample Input and Output: (Your code should print the red texts on the screen. Black texts are sample user inputs)

Sample Input

C1: P
C2: Q
C3: R
C4: S
Direction: L
num: 3

Sample Output

After rotating left 3 times-
C1: S
C2: P
C3: Q
C4: R

Sample Input

C1: A
C2: B
C3: C
C4: D
Direction: R
num: 6

Sample Output

After rotating right 6 times-
C1: C
C2: D
C3: A
C4: B

Problem 2. Inventory

Suppose, you are working in a store and you are tasked to check inventory. There are n different items in the inventory. For each item, you know its available amount and unit price. Your manager has given you a list that has the required amount of each item in the inventory. You are required to check the inventory to see if you have enough amounts of each item. If not, you must order for remaining amounts of items. Write a program that calculates the remaining amounts and the total cost of the order. For this problem, your input would be an integer n (number of different items) and 3 different arrays of size n. The arrays will have the unite price, available amount and required amount of each item respectively.

Sample Input and Output: (Your code should print the red texts on the screen. Black texts are sample user inputs)

Sample Input

Number of items: 3
Unit Price: 2 5 4
Available: 11 24 30
Required: 15 25 25

Sample Output

Remaining: 4 1 0
Total Cost of order: 13

Sample Input

Number of items: 3
Unit Price: 1 1 4
Available: 10 5 12
Required: 5 5 5

Sample Output

Remaining: 0 0 0
Total Cost of order: 0

Sample Input

Number of items: 5
Unit Price: 2 2 4 3 8
Available: 2 5 8 5 9
Required: 4 5 2 7 11

Sample Output

Remaining: 2 0 0 2 2
Total Cost of order: 26

Problem 3. Palindrome or Not!

A sequence is called Palindrome if it reads the same in both forward and reverse direction. Write a program that takes a character array as input and determines whether its palindrome or not. A character array is an array where each element of the array is a single character. For this problem, your input would an integer for the size of array and a character array. After checking, you are required to print whether its palindrome or not.

Sample Input

Enter Size: 7
Enter Sequence: A b c a c b A

Sample Output

Palindrome

Sample Input

Enter Size: 7
Enter Sequence: A b w a c b A

Sample Output

Not Palindrome

Sample Input

Enter Size: 8
Enter Sequence: p q x y Y x Q p

Sample Output

Not Palindrome

Sample Input

Enter Size: 8
Enter Sequence: p q x y y x q p

Sample Output

Palindrome

Problem 4. Sequence Matching

Sequence matching is a very interesting problem in various fields like genetics, cryptography etc. The main idea is that you are given a large sequence and a smaller sequence; you have to find whether the smaller sequence appears in any place of the large sequence. Write a program that performs this task. Your input would be 2 integers for array size and 2 integer arrays. Write a function that takes these 2 arrays as parameters and returns the index of the first occurrence of the smaller sequence in larger sequence. If no such match occurs, print proper message.

Sample Input and Output: (Your code should print the red texts on the screen. Black texts are sample user inputs)

Sample Input

Enter Size of A: 7
Enter A: 13 2 24 7 8 -9 0
Enter Size of B: 3
Enter B: 7 8 -9

Sample Output

Match Found at index 3.

Sample Input

Enter Size of A: 7
Enter A: 13 2 24 7 8 -9 0
Enter B: 4
Enter Size of A: 7 8 9 0

Sample Output

No match found.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.