Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • 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.

Students Click Here

Proble solving - can someone help?

Proble solving - can someone help?

Proble solving - can someone help?

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.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?

Thanks for your reply.

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.



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.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

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:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close