ECE 175: Computer Programming for Engineering Applications
- Kmgina
- Rating : 186
- Grade : A+
- Questions : 0
- Solutions : 462
- Blog : 1
- Earned : $47433.48
ECE 175: Computer Programming for Engineering Applications
Spring 2016
Lab Assignment #6 (Thursday session)
complete solutions correct answers key
Problem 1 (15 points): Develop a C program to find a lower triangular matrix of a given matrix A and a product of all diagonal elements of A.
Lower triangular matrix is a 2D array such that every elements above the main diagonal = 0.
Your program must be written using loops such that it works with any given SIZE of a matrix and should use the following prototypes:
#define SIZE 3 //Change this to match the size of matrix used in main()
//this function is to create lower triangular matrix of A (create A_lower)
void findLower(double A[][SIZE], double A_lower[][SIZE]);
//this function is to find product of all diagonal elements
void ProductDiagonal(double x[][SIZE], double *product);
//this function is to print 2D array x in a matrix format
void PrintMatrix(double x[][SIZE]);
Sample code execution 2:
M =
9.10 13.40 5.20 2.70
1.80 11.00 7.50 6.90
3.50 7.30 4.60 1.25
6.50 0.00 7.80 10.00
lower(M) =
9.10 0.00 0.00 0.00
1.80 11.00 0.00 0.00
3.50 7.30 4.60 0.00
6.50 0.00 7.80 10.00
Product of all diagonal elements = 4604.600
Press any key to continue . . .
You will initialize the 2D array (matrix) directly in your (main) code for given matrices (2D arrays) shown in sample code executions.
Sample code execution 1:
M =
0.71 -0.71 0.85
0.61 0.61 -0.50
0.35 0.35 0.87
lower(M) =
0.71 0.00 0.00
0.61 0.61 0.00
0.35 0.35 0.87
Product of all diagonal elements = 0.377
Press any key to continue . . .
Sample code execution 3:
Problem 2 (15 points):
A palindrome is a word that reads the same forward as it does backward.
- An example of a valid palindrome is the word "racecar".
- An example of a word that is not a palindrome is "trust" (it reads backwards as "tsurt").
Develop a C program that
- Ask a user to enter one word
- Decide whether the entered word is a palindrome
- Be interactive (q to quit, others to continue)
Note: assume that a maximum number of characters for one word is 50
See sample code execution below:
red – entered by a user
Enter a word: racecar
racecar is a palindrome
Press q/Q to quit, others to continue: y
Enter a word: trust
trust is NOT a palindrome
Press q/Q to quit, others to continue: t
Enter a word: detartrated
detartrated is a palindrome
Press q/Q to quit, others to continue: s
Enter a word: minimum
minimum is NOT a palindrome
Press q/Q to quit, others to continue: r
Enter a word: rotator
rotator is a palindrome
Press q/Q to quit, others to continue: a
Enter a word: 175ece571
175ece571 is a palindrome
Press q/Q to quit, others to continue: c
Enter a word: testset
testset is a palindrome
Press q/Q to quit, others to continue: q
[Solved] ECE 175: Computer Programming for Engineering Applications
- This solution is not purchased yet.
- Submitted On 18 Mar, 2016 01:26:46
- Kmgina
- Rating : 186
- Grade : A+
- Questions : 0
- Solutions : 462
- Blog : 1
- Earned : $47433.48