Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void setup() {
- // put your setup code here, to run once:
- Serial.begin(9600);
- }
- void loop() {
- // put your main code here, to run repeatedly:
- int a, b, c;
- Serial.print("Enter a: ");
- while (Serial.available() == 0) ;
- a = Serial.parseInt();
- Serial.println(a);
- Serial.print("Enter b: ");
- while (Serial.available() == 0) ;
- b = Serial.parseInt();
- Serial.println(b);
- Serial.print("Enter c: ");
- while (Serial.available() == 0) ;
- c = Serial.parseInt();
- Serial.println(c);
- Serial.println();
- int x1 = (-b + sqrt(b * b - 4 * a * c)) / (2 * a);
- int x2 = (-b - sqrt(b * b - 4 * a * c)) / (2 * a);
- Serial.print("x1=");
- Serial.println(x1);
- Serial.print("x2=");
- Serial.println(x2);
- Serial.println("******************************************");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement