Computer Science, asked by abhinavjain1307, 9 months ago

Write a menu driven program to perform the following operations using switch-case.

(a) Compute and display the sum of the following series:
S=X/1-X²/2+x³/3-....n terms

(b)Input an integer and print the sum of first and last digits of that number.
Example:

Input: n = 8452

Output: Sum of first and last digit = 8+2 = 10​

Answers

Answered by student304
0

#include <math.h>

#include <stdio.h>

  

// Function to get the series

double Series(double x, int n)

{

    double sum = 1, term = 1, fct, j, y = 2, m;

  

    // Sum of n-1 terms starting from 2nd term

    int i;

    for (i = 1; i < n; i++) {

        fct = 1;

        for (j = 1; j <= y; j++) {

            fct = fct * j;

        }

        term = term * (-1);

        m = term * pow(x, y) / fct;

        sum = sum + m;

        y += 2;

    }

    return sum;

}

  

// Driver Code

int main()

{

    double x = 9;

    int n = 10;

    printf("%.4f", Series(x, n));

    return 0;

}

Java

Python3

C#

PHP

hii mate hope it helps you it is only the answer no. 1 ....

ask again for the 2nd answer since its long ...

plz mrk me as brainlist....

plzzzzz

All the best for your life.......

Similar questions