Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm stuck from question 4 on. plz help int matrixA MAX DIM1 [MAXDIM matrixB [MAX DIM1 [MAX DIM sum [MAX DIM] [MAX DIM] int scores

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

I'm stuck from question 4 on. plz help

int matrixA MAX DIM1 [MAXDIM matrixB [MAX DIM1 [MAX DIM sum [MAX DIM] [MAX DIM] int scores [STUDENTS]; int *pscores = NULL; Question 1: Forward declaration (5 points) Declare here the functions used in the program, as needed // DO NOT modify main () int main() printf(" Problem 2, 3, 4, 5: n"); inputMatrixA () copyToMatrixB); addMatrix(); displaySumMatrix); printf ("nProblem 6,7: "); inputScores () scoresStats() getchar )/ printf ("nProblem 8 // neded to flushout Enter ( ) character left behind. Comment out if not needed "); createUsername(); printf (" Problem 9: "); lowerToUpperCase( ); printf("nProblem 10: "); searchPattern ); system ("pause"/eeded to keep console open in Vs Question 2: inputMatrixA (5 points) matrixA][ is already declared. Input the elements of matrixA from the user. Use the macro MAX_DIM in your code, so that when MAX_DIM is changed from 3 to any other number, this function would still work Note: Usually, matrix is entered row-wise. So input 1st row of elemets , followed by 2nd row and so on void inputMatrixA () Question 3: copyToMatrixB (5 points) matrixB is already declared. Compose matrixB identical to matrixA Copy elements of matrixA to matrixB. You may use array operation or pointer to do the copying. So, after calling this function, matrixB and matrixA should have same elements. Use the macro MAX_DIM in your code, so that when MAX_DIM is changed from 3 to any other number, this function would stil1 work Debug tip: Use display function below to temporarily display matrixA and matrixB to verify if your functions work correctly. void copyToMatrixB() Question 4: addMatrix (10 points) sum is already declared. Implement this math operation (2*A) + B and store the result in matrix 'sum'. Use the macro MAX DIM in your code, so that when MAX DIM is changed from 3 to any other number, this function would still work void addMatrix() Question 5: displaySumMatrix (10 points) Implement the function to display the sum' matrix. Display in this format: The matrix sum- void displaySumMatrix( Question 6: inputScores (10 points) Input the scores of students. The valid range of score is 0 to 100 (0 and 100 included). Keep prompting the user to input valid score if invalid score is input. This function should work as expected when STUDENTS macro is changed. You MUST use pointer'pScores' to input the scores to gain full points Using array operation (scores[i]) will earn you half points void inputScores () pScores-&scores [0] // enter code here Question 7: scoreStats (10 points) Now that the scores of students are stored, find the maximun and the average of those scores. Display these stats. gnore the decimal point accuracy since we are dealing with integers. This function should work as expected when STUDENTS macro is changed You MUST use pointer 'pScores' to gain full points Using array operation (scores[i]) will earn you half points Note: Make sure pointer 'pScores' is pointing to correct place. void scoreStats () Question 8: createUsername (15 points) Implement the function that creates and displays the user name of the user. Ask the user for their first and last name. The username is the first letter of first name, followed by the last name For instance, if the user's name is John Doe, then the username is jdoe The user may input upper or lower case characters for first and last name. Make sure that the usernameis all lower case. Note When using fgets , when you press Enter to finish entering the string, the Enter (n) character is also added to the string. Try to remove that character. void createUsername () char firstName [15], lastName [15], userName [20]; // enter code here printf ("User name : %s", userName ); Question 9: (10 points) Count the number of lower case characters in array 'sentence' and convert lower case characters to upper case. Print the number of lower case characters and print the newly formed sentence [] which has all upper case characters You may not add more variables than already declared. You may use 'int i' in 'for' loop, if needed. Hint: Lookup ASCII chart of alphabets void lowerToUpperCase () char sentence []="THS SentENCE HAS SOMe LoWEr CASE ChARACTERS"; int lowerCases0 // enter code here printf ("Number of lowe r case characters- %d ", printf("Upper case sentence : %s ", sentence); lowe rCases); Question 10 (20 points) Implement the function to take in a 10-character string 'string'1' and 3 character pattern string 'pattern' from the user. Search for the 'pattern' in 'str' and display "Pattern found" if 'pattern' is found in 'str, else display "Pattern not found". For instance, if user enters str-"abcdefghij" and pattern - "ghi", thern the pattern exists in str, so display"Pattern found". You MUST use pointers and not arrays for this question. You may use string functions. You may not add more variables than already declared. You may use 'int i' in 'for' loop, if needed. Note When using fgets , when you press Enter to finish entering the string, the Enter (n) character is also added to the string. Try to remove that character. So a 10-character string actually looks like "abcdefghij \0". So consider storing 12 elements for 10-character string. Assume user inputs correct length strings. void searchPattern () char *str, *pattern; int strLen-0, patternLen-0 // enter code here

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions