×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Proble solving - can someone help?

Proble solving - can someone help?

(OP)
I am new to c programming. Could someone help me to solve the following problem related to arrays and text file:

A company has a large number of text files. These files are organized as follows:

1. the first line contains a threshold value.
2. the second line specifies the number of rows in the matrix.
3. the third line specifies the number of columns in the matrix.
4. each remaining line is one row of the matrix.

1.3
5
3
1.1  1.9  1.4
0.9  1.8  1.1
1.8  1.6  0.4
0.6  0.2  1.7
0.4  1.4  0.3

Assume no. of rows <=20, no. of columns <= 15.

Write a program that asks the user to supply the name of an input file, reads the data from input file, and prints the following info:
1. The treshold value
2. The numbers of rows and columns in the matrix
3. For each column the number of values in that column that are greater than or equal to threshold value.
4.the average of elements in the matrix

Help would be highly appreciated.

RE: Proble solving - can someone help?

Post your attempt (i.e. the code) and describe the problems you're having with it and somebody will try to help you.  This looks like a copy and pasted homework assignment.

Russ
bobbitts@hotmail.com

RE: Proble solving - can someone help?

(OP)

As I said, I am new to c programming. I have taught myself the basics in preparation for an exam but I have no clue how to tackle this problem. I know how to open an input file and am familiar with arrays. But need direction to get started on this. Could not find a similar problem in any of the text books I could get. Thx.

RE: Proble solving - can someone help?

Do you know how to get user input? Do you at least have some skeleton code that opens a file and reads all the lines in the file? If so, post that.

A few hints: look into fgets() for user input and reading the file line by line, look into strtok() to parse the lines that contain the matrix values and strtof() or strtod() to convert the matrix values into numeric values.

Once you get some code together, post again.

HTH,

Russ
bobbitts@hotmail.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!