Question

1) Write an algorithm to calculate the sum of the following series:           Sum =x-x3/3! +...

1) Write an algorithm to calculate the sum of the following series:
          Sum =x-x3/3! + x5/5! – x7/7! +…….     Stop when the                     term<0.0001.

   2) An internet service provider charges its subscribers per month as follows:
          Data usage (n), in gbs           charges (NIS)
          0.0<n<=1.0                                250
          1.0<n<=2.0                                500
          2.0<n<=5.0                              1000
          5.0<n<=10.0                            1500
                  n>10                                 2000
         Write a C program to read the usage(n) from a file and print the charges to be paid by the subscribers.
          Your program must include the function calculate that accept the data usage (n) and returns the charge/month.

**please i need a unique answer
i dont want copy one

Homework Answers

Answer #1

Please give positive ratings for my efforts. Thanks.

ANSWER

#include<stdio.h>
#include<math.h>

int main() 
{ 
    float n;
    printf("Enter the valu of x :  ");
    scanf("%f",&n);

        float acc = 0.0001, den, sinx, sinval; 
        
        n = n * (3.142 / 180.0); 

        float x1 = n; 
        
        sinx = n;                
        
        sinval = sin(n);         
        int i = 1; 
        do
        { 
                den = 2 * i * (2 * i + 1); 
                x1 = -x1 * n * n / den; 
                sinx = sinx + x1; 
                i = i + 1; 
        } while (acc <= fabs(sinval - sinx)); 
        
        printf("\nResult :  %f",sinx); 
}
Know the answer?
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
Similar Questions
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT