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

 
An Inside Look at Apple’s New In-Store Pickup Service

An Inside Look at Apple’s New In-Store Pickup Service

A few weeks ago, Apple updated its retail store app with multiple new features. The two that really stood out were the EasyPay self-checkout option and the new in-store pickup service.

Giới thiệu REST Easy phần 2: Sub Property Boogaloo

Giới thiệu REST Easy phần 2: Sub Property Boogaloo

Hello again, RESTful friends. Welcome to episode II, The RESTful strikes back

Siri Proxy Makes Starting Your Car With Your Voice a Reality

Siri Proxy Makes Starting Your Car With Your Voice a Reality

A few days ago we told you about one clever fellow who had found a way to create a ‘Siri proxy,’ allowing him to intercept Siri commands.

Tomdesgin.vn

 

Drupal Services