Question

Image for 1 .Write a e program using the following structure to hold the compression load, p, and the diameter, cl, of a

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <stdio.h>

#include <stdlib.h>

#include <math.h>

#define E 30000000   //elasticity value of steel

#define PI 3.14

struct Strength

{

  float p;

  float d;

  float l;

  float stress;

  float strain;

};


int main()

{

  FILE *rptr;

  FILE *wptr;

  

  rptr=fopen("input.txt","r");

  wptr=fopen("output.txt","wb");

  

  float area;

  struct Strength steel;

  

  while(fscanf(rptr," %f %f %f ",&steel.p,&steel.d,&steel.l)==3)       //reading from file

  {

    area=PI*(steel.d * steel.d)/4;

    steel.stress= steel.p/area;       //as formulae described in problem

    steel.strain=steel.stress/E;

    

    fprintf(wptr,"%f %f %f %f",steel.p,steel.d,steel.stress,steel.strain); //writing into file

    fprintf(wptr,"\n");

    

  }

  

  return 0;

}


answered by: codegates
Add a comment
Know the answer?
Add Answer to:
1 .Write a e program using the following structure to hold the compression load, p, and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT