ProgIng - Programación en Ingeniería
Loading...
Searching...
No Matches
Ejemplo003.c File Reference
#include <stdio.h>
#include <math.h>
Include dependency graph for Ejemplo003.c:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 4 of file Ejemplo003.c.

5{
6 float a, b, c, x1r, x2r, x1i, x2i, r;
7 printf("Ingrese el valor de a: ");
8 scanf("%f", &a);
9 printf("Ingrese el valor de b: ");
10 scanf("%f", &b);
11 printf("Ingrese el valor de c: ");
12 scanf("%f", &c);
13 r = b*b-4*a*c;
14 x1r=(-b+(r>=0?sqrt(r):0))/(2*a);
15 x2r=(-b-(r>=0?sqrt(r):0))/(2*a);
16 x1i=(r>=0?0:sqrt(-r)/(2*a));
17 x2i=-x1i;
18 printf("x1=%.2f%+.2fi\n", x1r, x1i);
19 printf("x2=%.2f%+.2fi\n", x2r, x2i);
20 return 0;
21}