be created by you and after creation you must save some radius in this input

Be created by you and after creation you must save

This preview shows page 2 - 4 out of 4 pages.

be created by you and after creation you must save some radius in this input file */ if(inp==NULL)  // to check input file is opened properly or not  { printf("Not able to open input file"); exit(1);  // terminates the program // end of if      /* Open the output file  */ outp = fopen("circle.out", "w");   /* Read the radius from circle.dat  data file file    */
Image of page 2
fscanf(inp, "%lf", &radius); /* Stores (Saves ) following fprinf statement’s O/P in circle.out output file */ fprintf(outp, "The radius is %.2f\n", radius);   /* Calculate the area    */ area = PI * radius * radius;   /* Calculate the circumference   */ circum = 2 * PI * radius;   /* Following fprintf statements Stores the area and circumference in  output file circle.out   */ fprintf(outp, "The area is %.2f\n", area); fprintf(outp, "The circumference is %.2f\n", circum);   /* Close input and output files   */ fclose(inp); fclose(outp); return (0);  // returns 0 integer value to operating system // end of main Example #2 : /*Miles-to-Kilometers Conversion Program with Named Files */ /* Converts distances from miles to kilometers.   */ #include <stdio.h>     /* printf, scanf, fprint, fscanf, fopen, fclose  definitions */ #include<stdlib.h>  // it used here because of exit( ) function #define KMS_PER_MILE 1.609  /* conversion constant  */ int main(void)  {   double miles,  /* distance in miles */               kms;   
Image of page 3
Image of page 4

You've reached the end of your free preview.

Want to read all 4 pages?

  • Spring '10
  • zaman
  • Input/output, input file, input data file, outp

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes