Matlab Programming Write a program to open a file called myd

Matlab Programming

Write a program to open a file called \"mydata\" the link for it is http://carmaux.cs.gsu.edu/~mweeks/csc4630/mydata, read the contents, up to the first 200 characters, and close the file. Have your program go through the data that it read, changing any number less than 32 to the value 32. Then display the data as a string. (The value 32 is the ASCII code for a space. This means that your program will replace any non-printable characters with spaces.)

Thanks

Solution

#include // Needed to use IO functions int main() { int sumOdd = 0; // For accumulating odd numbers, init to 0 int sumEven = 0; // For accumulating even numbers, init to 0 int upperbound; // Sum from 1 to this upperbound int absDiff; // The absolute difference between the two sums // Prompt user for an upperbound printf(\"Enter the upperbound: \"); scanf(\"%d\", &upperbound); // Use %d to read an int // Use a while-loop to repeatedly add 1, 2, 3,..., to the upperbound int number = 1; while (number <= upperbound) { if (number % 2 == 0) { // Even number sumEven += number; // Add number into sumEven } else { // Odd number sumOdd += number; // Add number into sumOdd } ++number; // increment number by 1 } // Compute the absolute difference between the two sums if (sumOdd > sumEven) { absDiff = sumOdd - sumEven; } else { absDiff = sumEven - sumOdd; } // Print the results printf(\"The sum of odd numbers is %d.\ \", sumOdd); printf(\"The sum of even numbers is %d.\ \", sumEven); printf(\"The absolute difference is %d.\ \", absDiff); return 0; }
Matlab Programming Write a program to open a file called \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site