Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Shaheed Zulfikar Ali Bhutto Institute of Science & Technology

COMPUTER SCIENCE DEPARTMENT

Total Marks:

Obtained Marks:

Date:

Fundamentals of
Programming (FOP)
Assignment # 1

Submitted To: Ms. Zainab Iftikhar

Student Name: Abid Ali Akbar

Reg. Number: 2273107

FOP MSCS-1 SZABIST-ISB


Shaheed Zulfikar Ali Bhutto Institute of Science & Technology

COMPUTER SCIENCE DEPARTMENT


Question No: 01 . Write a C++ program to solve quadratic equation also draw its flow chart.

Code:
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
float a, b, c, deter, x1, x2;

cout << "Enter the values of a: " ;


cin >> a;
cout << "Enter the values of b: " ;
cin >> b;
cout << "Enter the values of c: ";
cin >> c;

if (a==0 && b==0)


{
cout<<" This is not a Quadratic Equation";
}
else
{
deter = b*b - 4*a*c;
if (deter>=0)
{
x1 = (-b + sqrt(deter))/(2*a);
x1 = (-b - sqrt(deter))/(2*a);
cout<<" Roots are real"<<endl;
cout<<"Root No. 1 = "<<x1<<endl;
cout<<"Root No. 2 = "<<x2<<endl;
}

else
{
cout<<" Roots are not real";
}
}
}

FOP MSCS-1 SZABIST-ISB


Shaheed Zulfikar Ali Bhutto Institute of Science & Technology
Screenshot.

Flow Chart.

FOP MSCS-1 SZABIST-ISB

You might also like