Results 1 to 3 of 3

Thread: Need help with exiting code error

  1. #1
    Join Date
    Oct 2012
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Need help with exiting code error

    So I wrote a program that worked in Microsoft visual c++ and when I loaded it into Qt Creator and try to run the program. I get the error "exited with code 1073807364". This program is pretty simple and solves quadratic equations but I just don't know how to fix this problem. Any help would be appreciated please and thank you. Here is my code:


    #include <iostream>
    #include <cmath>
    #include <complex>
    #include <queue>
    #include <windows.h>
    #include <QtGui/QApplication>
    #include "mainwindow.h"

    using namespace std;

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    MainWindow w;
    w.show();


    double x_squared, x, c;

    cout << "Enter the value for x squared..." <<endl;
    cin >> x_squared;
    cout << "Enter the value for x..." <<endl;
    cin >> x;
    cout << "Enter the value for c..." <<endl;
    cin >> c;



    double discriminant = (pow(x,2) - 4*x_squared*c);
    double positive_root = (((-x + sqrt(discriminant))/(2*x_squared)));
    double negative_root = (((-x - sqrt(discriminant))/(2*x_squared)));


    if (discriminant == 0)
    {
    cout << "\n\nThe discriminant is ";
    cout << discriminant << endl;
    cout << "The equation has a single root.\n\n";
    }

    else if (discriminant <0)
    {
    cout << "\n\nThe discriminant is ";
    cout << discriminant << endl;
    cout << "The equation two complex roots.\n\n";
    }

    else
    {
    cout << "\n\nThe discriminant is ";
    cout << discriminant << endl;
    cout << "The equation two real roots.\n\n";
    }


    cout << "The roots of the quadratic equation are x = ";
    cout << negative_root;
    cout << ", ";
    cout << positive_root << endl;

    return a.exec();
    }

  2. #2
    Join Date
    Sep 2012
    Location
    Iran, Tehran
    Posts
    76
    Thanks
    17
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Need help with exiting code error

    Does this sqrt function that you have used accepts negative values? If not check discriminant value before passing it to sqrt. Also make sure x_squared is not zero.
    Last edited by Ashkan_s; 18th October 2012 at 20:37.

  3. #3
    Join Date
    Oct 2012
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Need help with exiting code error

    thank you very much.

Similar Threads

  1. Replies: 1
    Last Post: 13th September 2011, 09:56
  2. Error Exiting slot calls
    By jacks916 in forum Qt Programming
    Replies: 10
    Last Post: 11th August 2011, 12:19
  3. Error code after inheriting QGraphicsView
    By K.Sejdak in forum Qt Programming
    Replies: 12
    Last Post: 13th March 2011, 22:24
  4. exited with code -1073741819 error
    By arpspatel in forum Qt Programming
    Replies: 8
    Last Post: 2nd March 2010, 09:47
  5. Error in Q3Canvas Code...
    By Kapil in forum Newbie
    Replies: 10
    Last Post: 27th March 2006, 05:15

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.