0% found this document useful (0 votes)
9 views

Using System

The document contains code for two C# programs. The first program calculates the value of a quadratic equation for values of x from 1 to 100, and prints messages for changes in sign from positive to negative or vice versa. The second program requests two integer inputs, ensures the second is not less than the first, then calculates and prints the nth Fibonacci number based on a user-specified term.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Using System

The document contains code for two C# programs. The first program calculates the value of a quadratic equation for values of x from 1 to 100, and prints messages for changes in sign from positive to negative or vice versa. The second program requests two integer inputs, ensures the second is not less than the first, then calculates and prints the nth Fibonacci number based on a user-specified term.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace tarea4JPPB

class Program

static void Main(string[] args)

System.Console.WriteLine("Nombre:Nabil Alvarez ");

System.Console.WriteLine("Matricula:2959714");

double x, z;

bool n;

n = true;

for(x=1; x<100;x++)

z = Math.Pow(x, 2) - 100*(x) + 900;

System.Console.WriteLine(z);

if (z>0 & n==true)

else

if (z>0 & n == false)

System.Console.WriteLine("Hubo un cambio de negativo a


positivo");

n = true;

else

if (z<0 & n==true)

System.Console.WriteLine("Hubo un cambio de signo de

positivo a negativo ");

n = false;

Console.ReadLine();

}
Part 2

sing System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace Tarea4programa2JPPB

class Program

static void Main(string[] args)

System.Console.WriteLine("Nombre:Johana Paulina Pintor Barrón");

System.Console.WriteLine("Matricula:2924305");

int numero_ 1, numero_2;

System.Console.WriteLine("Dame el numero 1");

numero_1 = int.Parse(Console.ReadLine());

System.Console.WriteLine("Dame el numero 2");

numero_2 = int.Parse(Console.ReadLine());

while (numero_2 < numero_1)

System.Console.WriteLine("0 es menor que 1, se vuelve a repetir

el mismo numero", numero_2, numero_1);

numero_2 = int.Parse(Console.ReadLine());

double fibonacci = 0, fibonacci_pasado = 1, fibonacci_antepas = 1;

int S, a;
Console.Write("¿Que termino desea obtener?");

S = int.Parse(Console.ReadLine());

for (a = 1; a <= S - 2; a=a+1)

fibonacci = fibonacci_pasado + fibonacci_antepas;

fibonacci_antepas = fibonacci_pasado;fibonacci_pasado =

fibonacci;

Console.WriteLine("S" + S + "es" + fibonacci);

System.Console.ReadLine();

You might also like