0
Speak People! I’m using Visual Studio to learn C# , I created a button that when clicked should show the result of a Bhaskara formula. But everything that appears on the screen when testing boils down to "Nan"
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace bhaskara
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
/*Fórmula de Bhaskara -- */
int a = 2, b = 2, c = 4;
double delta, xl, xll , raizq;
delta = (b * b) * (-4) * a * c;
xl = ((-b) + Math.Sqrt(delta)) / 2 * a;
xll = ((-b) - Math.Sqrt(delta)) / 2 * a;
MessageBox.Show("O resultado do x linha é :" + xl);
MessageBox.Show("Já o resultado de x duas linha é:" + xll);
}
}
}
You did a background check for the case :
delta < 0
?– Tuxpilgrim