Advertisement
semenrbt

Kristina_1.3.2

Feb 4th, 2020
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. int main() {
  6.     float a = 0;
  7.     float b = 0;
  8.     float h = 0;
  9.     printf("Enter a = ");
  10.     if(scanf("%f", &a) != 1)
  11.     {              
  12.         printf("Error.\n");
  13.         return 0;
  14.     }
  15.     printf("Enter b = ");
  16.     if(scanf("%f", &b) != 1)
  17.     {              
  18.         printf("Error.\n");
  19.         return 0;
  20.     }
  21.     printf("Enter h = ");
  22.     if(scanf("%f", &h) != 1)
  23.     {              
  24.         printf("Error.\n");
  25.         return 0;
  26.     }
  27.     if(a > b || h <= 0)
  28.     {
  29.         printf("Input Error.");
  30.         return 0;
  31.     }
  32.     printf("x\ty(x)\n");
  33.     printf("%f\n", cos(a));
  34.     float o = a+h;
  35.     while(o <= b)
  36.     {
  37.         printf("%f\t%f\n", o, cos(o));
  38.         o = o + h;
  39.     }
  40.  
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement