Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.24 KB | None | 0 0
  1. //
  2. //  main.c
  3. //  prog5_integral
  4. //
  5. //  Created by James Moriarty on 10/24/16.
  6. //  Copyright © 2016 James Moriarty. All rights reserved.
  7. //
  8.  
  9. #define _CRT_SECURE_NO_WARNINGS
  10. #include <stdio.h>
  11. #include "prog5_functions.h"
  12.  
  13. int main() {
  14.     //a low point, b hi n is number of trapezoids junk clears line
  15.     char junk;
  16.     float a,b,n;
  17.     int nval;
  18.     char yn;
  19.     double area_final;
  20.     while(nval!=2)  // loop repeats until nval=2 which is proper format
  21.         do{
  22.     printf("Enter endpoints of interval to be imtegrated <low hi>: ");
  23.     nval=scanf("%f %f",&a, &b);
  24.             printf("\nEnter the number of trapezoids to be used: ");
  25.             scanf("%f", &n);
  26.             if (nval==2 && a<b && n>=1)
  27.         break;
  28.     // other wise clears line
  29.         else if (a>b)
  30.             printf("Error: low < hi \n");
  31.         else if (n<1)
  32.             printf("Error numT must be >1");
  33.     do {
  34.         scanf("%c", &junk);
  35.     } while (junk != '\n');
  36. } while (nval!=2);
  37.     // unsure what to set return to to rerun prog.
  38.     return(0);
  39.     // not sure if I am calling integrate correctly.
  40.     double integrate ();
  41.     area_final = integrate (a,b,n);
  42.    
  43.    
  44.     printf("Evaluate another integral <Y/N>?");
  45.     scanf("%c", &yn);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement