Bài 18: Tính S(n) = 1 + x^2/2! + x^4/4! + … + x^2n/(2n)!

Bài 18: Tính S(n) = 1 + x^2/2! + x^4/4! + … + x^2n/(2n)!

Bài tập 18 (Dạng bài tập này giúp các bạn giỏi về: Lưu đồ thuật toán)

Tính S(n) = 1 + x^2/2! + x^4/4! + … + x^2n/(2n)!

Cài đặt

#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
    int i, n;
    float x, S, T;
    long M, N;
    printf("\nNhap x: ");
    scanf("%f", &x);
    do
    {
    printf("\nNhap n(n >= 0) : ");
    scanf("%d", &n);
      if(n < 0)
      {
          printf("\n N phai >= 0. Xin nhap lai !");
      }

    }while(n < 0);

    S = 1;
    N = 1;
    i = 1;

    while(i <= n)
    {
        T = pow(x, (2 * i ));
        M = i * 2;
        N = N * M * (M - 1);
        S = S + T/N;
        i++;
    }
    printf("\nTong la %f", S);
    getch();
    return 0;
}
Bạn thấy bài viết này như thế nào?: 
Average: 10 (4 votes)
Ảnh của Tommy Tran

Tommy owner Express Magazine

Drupal Developer having 9+ year experience, implementation and having strong knowledge of technical specifications, workflow development. Ability to perform effectively and efficiently in team and individually. Always enthusiastic and interseted to study new technologies

  • Skype ID: tthanhthuy

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
iPhone, iPad cũng bị cài sẵn phần mềm gián điệp

iPhone, iPad cũng bị cài sẵn phần mềm gián điệp

Apple xác nhận thông tin những phiên bản iOS trước đây đều hỗ trợ phần mềm “gián điệp” Carrier IQ.

Sử dụng Git workflow quản lý Drupal 8 configuration

Sử dụng Git workflow quản lý Drupal 8 configuration

We will assume that you have a development version of Drupal 8, git and drush available on your system

HTC Salsa: A Review

HTC Salsa: A Review

The name salsa sounds fun, warm an inviting, and yes, it is true of the HTC Salsa. The first thing that caught my eye was the build quality.

Công ty diệt chuột T&C

 

Diet con trung