Please answer 7. Write a function that ask the user to enter up to a maxSize cha
ID: 3754031 • Letter: P
Question
Please answer 7.
Write a function that ask the user to enter up to a maxSize char static array. Input can be less than maxSize and is stopped by entering non-alphabet letter, using the isalpha([char]) function in the cctype library. 1. Assuming the user will only enter all lower-case letter, write a function that returns the highest number of occurrences in the user input array using Q1. If two or more characters have the same number of occurrences, return the one closest to a. 2. 3. Write a function that ask the user the number of shift they want and shift the array according. Note: You CANNOT use any additional arrays. You should write a swap function. For example, if the input characters are a bcadebc a and the number of spaces to shift is 3, the output will be: b ca a b cade If the number of spaces is negative, the shift will be to the left. Write a function that combine a sorted char static array arl with size nl and a sorted char static array ar2 with size n2 and return one sorted char array of the combine of those two arrav 4. For example: ar1 [n1] {'a,,'c','e','f'); ar2[n2] ('h','d','g'); = newn]-'a, 'b' 'c', 'd', 'e', f, "g'; 5. W rite a function that ask the user for m and n where m and n is the size of the m-x-n ch matrix and lets them input into the matrix. 6. Write a function that ask the user the number of rotations they want and rotate the matrix 90 degree according. This can only be done with a square matrix. Note: You CANNOT use any additional arrays/matrix For example, if the input characters matrix is a b c d and the number of rotations is 2, the output will be d c b aExplanation / Answer
7 PROBLEM PROGRAM USING C++
#include<iostream>
using namespace std;
void enlargeMat(char a[][10],int m,int n,int size)
{
for(int i=0;i<m;i++) // create for i loop until m rows
{
for(int t=0;t<size;t++) // create for t until size outer loop
{
for(int j=0;j<n;j++) // create for j loop until n columns
{
for(int k=0;k<size;k++) // create for k for loop until size display size times
{
cout<<a[i][j]<<" "; // display elements
}
}
cout<<endl; // next line
}
}
}
int main()
{
char a[10][10];
int size,n,m;
cout<<"Enter n X m: "; cin>>n>>m;
cout<<"Enter "<<n<<"X"<<m<<" Array"<<endl;
// read 2d matrix
for(int i=0;i<2;i++)
for(int j=0;j<3;j++)
cin>>a[i][j];
cout<<"Enter Size : "; cin>>size;
enlargeMat(a,2,3,size); // calling enlargeMat() function
return 0;
}
OUTPUT-1
Enter n X m: 2 3
Enter 2X3 Array
a b c
d e f
Enter Size : 2
a a b b c c
a a b b c c
d d e e f f
d d e e f f
OUTPUT-2
Enter n X m: 2 3
Enter 2X3 Array
a b c
d e f
Enter Size : 3
a a a b b b c c c
a a a b b b c c c
a a a b b b c c c
d d d e e e f f f
d d d e e e f f f
d d d e e e f f f
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.