Вы находитесь на странице: 1из 3

Pregunta Nmero 20:

Disee un programa que calcule el valor de PI de acuerdo a la siguiente expresin:

Solucin:
Seudocdigo:
Variables de entrada:
n: entero (es la cantidad de trminos a ingresar)
Variables auxiliares:
i: entero (variable contador de numero de trminos)
fraccin

: doble (variable para calcular la division de 4 entre denominador)

denom

: doble (variable denominador de la fraccin)

Variables de salida:
sumaPi

: doble (variable que calcula la sumatoria de los n trminos)

Inicio{ingresar nmero de trminos de la serie:}


i1
n0
fraccion0

fin

denom1
sumaPi0
mientras(i<=n)
inicio
fraccion (4 / denom);
si(i mod 2 =0) entonces
inicio
fraccion(-1)*(4 / denom)
fin
Cdigo fuente en C#
sumaPisumaPi + fraccion
denomdenom + 2
int i = 1;
ii + 1;
int n = 0;
fin
double fraccion = 0;
escribir(La suma de los n terminus es:,sumaPi)
double denom = 1;
double sumaPi = 0;
System.Console.WriteLine("Ingresecantidad de series:");
n = int.Parse(System.Console.ReadLine());
while (i<= n) {
fraccion = (4 / denom);
if ((i % 2) == 0) fraccion =(-1)*(4 / denom);
sumaPi = sumaPi + fraccion;
denom = denom + 2;
i++;
}
//imprimo los resultados
System.Console.Write("El valor de Pi es="+sumaPi);
System.Console.ReadKey();

Preg 19

Cdigo fuente en C#
int n = 0;
int i = 1;
int actual = 1;
int anterior=0;
int suma = 0;
System.Console.Write("Ingrese el nmero de terminos de la seriee:");
n =int.Parse(System.Console.ReadLine());//1,2,3,5,8
while (i <= n) {
suma = actual + anterior;
anterior = actual;
actual = suma;
i++;
}
System.Console.Write("El n termino es:"+actual);
System.Console.ReadKey();

Preg. 17

Cdigo fuente en C#
int n = 0;
double fraccion = 0;
double sumaserie = 0;
double denom=1;
System.Console.WriteLine("Ingrese cantidad de series:");
n = int.Parse(System.Console.ReadLine());
while (denom <= n) {
fraccion = (1 / denom);
if ((denom % 2) == 0) fraccion =(-1)*(1 / denom);
sumaserie = sumaserie + fraccion;
denom = denom + 1;
}
//imprimo los resultados
System.Console.Write("El valor de Pi es="+ sumaserie);
System.Console.ReadKey();

Вам также может понравиться

  • Fortalezas situacionales
    Fortalezas situacionales
    Документ1 страница
    Fortalezas situacionales
    Yhan Rayme Arce
    Оценок пока нет
  • 1° Rúbrica 04
    1° Rúbrica 04
    Документ1 страница
    1° Rúbrica 04
    Roy Vargas
    Оценок пока нет
  • Variables de Servidor en Asp - Et
    Variables de Servidor en Asp - Et
    Документ1 страница
    Variables de Servidor en Asp - Et
    Yhan Rayme Arce
    Оценок пока нет
  • Resolucion Vulnerables
    Resolucion Vulnerables
    Документ12 страниц
    Resolucion Vulnerables
    Yhan Rayme Arce
    Оценок пока нет
  • 1° Links 04
    1° Links 04
    Документ1 страница
    1° Links 04
    Yhan Rayme Arce
    Оценок пока нет
  • Control de Requisitos
    Control de Requisitos
    Документ3 страницы
    Control de Requisitos
    Yhan Rayme Arce
    Оценок пока нет
  • Desarrollo Seguro
    Desarrollo Seguro
    Документ5 страниц
    Desarrollo Seguro
    Yhan Rayme Arce
    Оценок пока нет
  • AGENDA SESIÓN 05 - Tagged
    AGENDA SESIÓN 05 - Tagged
    Документ1 страница
    AGENDA SESIÓN 05 - Tagged
    JOSE MANUEL ALEXIS RAMIREZ PE�A
    Оценок пока нет
  • 1° Rubrica 04
    1° Rubrica 04
    Документ1 страница
    1° Rubrica 04
    Yhan Rayme Arce
    Оценок пока нет
  • Stopper Alternativa Web
    Stopper Alternativa Web
    Документ7 страниц
    Stopper Alternativa Web
    Yhan Rayme Arce
    Оценок пока нет
  • Sistema Económico
    Sistema Económico
    Документ2 страницы
    Sistema Económico
    Yhan Rayme Arce
    Оценок пока нет
  • Prevencion Ataques
    Prevencion Ataques
    Документ5 страниц
    Prevencion Ataques
    Yhan Rayme Arce
    Оценок пока нет
  • La Reflexion y Refraccion
    La Reflexion y Refraccion
    Документ3 страницы
    La Reflexion y Refraccion
    Yhan Rayme Arce
    Оценок пока нет
  • Caso Diseño
    Caso Diseño
    Документ2 страницы
    Caso Diseño
    Yhan Rayme Arce
    Оценок пока нет
  • Estructura Del Software Comep
    Estructura Del Software Comep
    Документ5 страниц
    Estructura Del Software Comep
    Yhan Rayme Arce
    Оценок пока нет
  • Modelamiento de Base de Datos
    Modelamiento de Base de Datos
    Документ8 страниц
    Modelamiento de Base de Datos
    Yhan Rayme Arce
    Оценок пока нет
  • Imprimir y validar DW PB
    Imprimir y validar DW PB
    Документ2 страницы
    Imprimir y validar DW PB
    Yhan Rayme Arce
    Оценок пока нет
  • Ms Project
    Ms Project
    Документ14 страниц
    Ms Project
    Yhan Rayme Arce
    Оценок пока нет
  • Sicologia Laboral
    Sicologia Laboral
    Документ77 страниц
    Sicologia Laboral
    Yhan Rayme Arce
    Оценок пока нет
  • Conexiones Concurrentes en Windows
    Conexiones Concurrentes en Windows
    Документ1 страница
    Conexiones Concurrentes en Windows
    Yhan Rayme Arce
    Оценок пока нет
  • Py Farmacia
    Py Farmacia
    Документ25 страниц
    Py Farmacia
    Yhan Rayme Arce
    Оценок пока нет
  • Proyecto. Limaqpuquio
    Proyecto. Limaqpuquio
    Документ12 страниц
    Proyecto. Limaqpuquio
    Yhan Rayme Arce
    Оценок пока нет
  • Triggers en MySQL
    Triggers en MySQL
    Документ7 страниц
    Triggers en MySQL
    Yhan Rayme Arce
    Оценок пока нет
  • Plan Al 2020.
    Plan Al 2020.
    Документ23 страницы
    Plan Al 2020.
    Yhan Rayme Arce
    Оценок пока нет
  • Sublime Text 2
    Sublime Text 2
    Документ53 страницы
    Sublime Text 2
    Jorge Eduardo Castillo Barron
    Оценок пока нет
  • Formato Ejemplo para Documentar El Uso de Scrum en Un Proyecto
    Formato Ejemplo para Documentar El Uso de Scrum en Un Proyecto
    Документ14 страниц
    Formato Ejemplo para Documentar El Uso de Scrum en Un Proyecto
    Juan David Castro
    100% (2)
  • Implementación Base de Datos MySQL
    Implementación Base de Datos MySQL
    Документ160 страниц
    Implementación Base de Datos MySQL
    oberta
    100% (2)
  • Caso Practico
    Caso Practico
    Документ2 страницы
    Caso Practico
    Yhan Rayme Arce
    Оценок пока нет
  • Metodo Roy
    Metodo Roy
    Документ26 страниц
    Metodo Roy
    Yhan Rayme Arce
    Оценок пока нет