I need a flow chart for this code.
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int cont;
float a, b, c, d, x1,x2;//coeficientes,discriminante y raices de equaciones en float.
cout<<"Este programa tienen como propósito el brindarle al usuario"<<endl;
cout<<"las soluciones o raices."<<endl;
do
{
cout << "Por favor ingrese el valor de a: ";//Pedimos a
cin >> a;
cout << "Por favor ingrese el valor de b: ";//Pedimos b
cin >> b;
cout << "Por favor ingrese el valor de c: ";//Pedimos c
cin >> c;
d = b*b - 4*a*c;//Formula cuadrática
if(d > 0.0f){//raices distintas
cout << "Las soluciones son reales y distintas"<<endl;
x1 = (-b + sqrt(d))/(2*a);
x2 = (-b - sqrt(d))/(2*a);
cout << "x1: " << x1 << " x2: " << x2 << endl;//imprimimos raices
}
else if (d < 0.0f){//raices imaginarias
cout << "La solucion es imaginaria"<<endl;
cout << "x1: " << -b/(2*a) << -sqrt(-d)/(2*a) << "j" << endl;//imprimimos primerea raiz
cout << "x2: " << -b/(2*a) << "+" << sqrt(-d)/(2*a) << "j" << endl;//imprimimos segunda raiz
}
else{ //Raices iguales
cout << "La solucion es real doble"<<endl;
x2 = x1 = -b/(2*a);
cout << "x1 y x2: " << x1 << endl<<endl;//imprimimos raices
}
cout<<"Si desea terminar ingrese el número cero: ";
cin>>cont;
}while (cont!=0);
return 0;
}
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images
- C++ complete magic Square #include <iostream> using namespace std; /*int f( int x, int y, int* p, int* q ){if ( y == 0 ){p = 0, q = 0;return 404; // status: Error 404}*p = x * y; // product*q = x / y; // quotient return 200; // status: OK 200} int main(){int p, q;int status = f(10, 2, &p, &q);if ( status == 404 ){cout << "[ERR] / by zero!" << endl;return 0;}cout << p << endl;cout << q << endl; return 0;}*/ /*struct F_Return{int p;int q;int status;}; F_Return f( int x, int y ){F_Return r;if ( y == 0 ){r.p = 0, r.q = 0;r.status = 404;return r;}r.p = x * y;r.q = x / y;r.status = 200;return r;} int main(){F_Return r = f(10, 0);if ( r.status == 404 ){cout << "[ERR] / by zero" << endl;return 0;}cout << r.p << endl;cout << r.q << endl;return 0;}*/ int sumByRow(int *m, int nrow, int ncol, int row){ int total = 0;for ( int j = 0; j < ncol; j++ ){total += m[row * ncol + j]; //m[row][j];}return total; } /*…arrow_forwardC++ Find the errors in the code for Date Class and Source.cpp program and fix them. source.cpp include <iostream>#include "Date.h" // include definition of class Date from Date.h using namespace std; // function main begins program executionint main(){Date date(); // create a Date object for May 6, 1981 // display the values of the three Date data members cout << "Month: " << date.getMonth() << endl;cout « "Day: " << date.getDay() << endl;cout << "Year: " << date.getYear(2017) << endl; cout << "\nOriginal date:" << endl;date = displayDate(); // output the Date// modify the Date setMonth(13);setDay(1);setYear(2005); cout "\nNew date:" << endl;date.displayDate(); // output the modified date } // end main Date.h // class Data definition#include <iostream>using namespace std; //Data constructor that initializes the three data members;class Date{publicdate(m, d, y){setMonth();setDay();setYear();};// set monthvoid…arrow_forward// SumAndProduct.cpp - This program computes sums and products // Input: Interactive// Output: Computed sum and product #include <iostream>#include <string>void sums(int);void products(int);using namespace std; int main() { int number; cout << "Enter a positive integer or 0 to quit: "; cin >> number; while(number != 0) { // Call sums function here // Call products function here cout << "Enter a positive integer or 0 to quit: "; cin >> number; } return 0;} // End of main function// Write sums function here// Write products function herearrow_forward
- #include <iostream> #include <cmath> using namespace std; // declare functions void display_menu(); void convert_temp(); double to_celsius(double fahrenheit); double to_fahrenheit(double celsius); int main() { cout << "Convert Temperatures\n\n"; display_menu(); char again = 'y'; while (again == 'y') { convert_temp(); cout << "Convert another temperature? (y/n): "; cin >> again; cout << endl; } cout << "Bye!\n"; } // define functions void display_menu() { cout << "MENU\n" << "1. Fahrenheit to Celsius\n" << "2. Celsius to Fahrenheit\n\n"; } void convert_temp() { int option; cout << "Enter a menu option: "; cin >> option; double f = 0.0; double c = 0.0; switch (option) { case 1: cout << "Enter degrees Fahrenheit: "; cin >> f; c =…arrow_forward//I need help debugging the C code below the image is what I was following for directions while doing the code// #include <stdio.h> #include <stdlib.h> struct employees { char name[20]; int ssn[9]; int yearBorn, salary; }; // function to read the employee data from the user void readEmployee(struct employees *emp) { printf("Enter name: "); gets(emp->name); printf("Enter ssn: "); for (int i = 0; i < 9; i++) scanf("%d", &emp->ssn[i]); printf("Enter birth year: "); scanf("%d", &emp->yearBorn); printf("Enter salary: "); scanf("%d", &emp->salary); } // function to create a pointer of employee type struct employees *createEmployee() { // creating the pointer struct employees *emp = malloc(sizeof(struct employees)); // function to read the data readEmployee(emp); // returning the data return emp; } // function to print the employee data to console void display(struct…arrow_forward5. Memory Layout Given the C struct definition below struct Simplestruct { int i; char c; double d; unsigned char a[11]; float f; }; struct Simplestruct ssp; Assume that int's are 4 bytes and have 4 byte alignment and that double has 8 byte alignment and float has 4 byte alignment. if calling printf("$x\n",ssp) yields CA028, what is the address of each field? You should express the answers in hexadecimal. &ssp->i = &ssp->c = &ssp->d = &ssp->a = &ssp->f =arrow_forward
- Q in picture **C PROGRAMMING LANGUAGE ***PROVIDE COMMENTSarrow_forwardC++ 6.34 #include <iostream>#include <cstdlib>#include <ctime>using namespace std; void guessGame(); // function prototypebool isCorrect( int, int ); // function prototype int main(){srand( time( 0 ) ); // seed random number generatorguessGame();} // end main // guessGame generates numbers between 1 and 1000 and checks user's guessvoid guessGame(){int answer; // randomly generated numberint guess; // user's guesschar response; // 'y' or 'n' response to continue game // loop until user types 'n' to quit gamedo {// generate random number between 1 and 1000// 1 is shift, 1000 is scaling factoranswer = 1 + rand() % 1000; // prompt for guesscout << "I have a number between 1 and 1000.\n" << "Can you guess my number?\n" << "Please type your first guess." << endl << "? ";cin >> guess; // loop until correct numberwhile ( !isCorrect( guess, answer ) ) cin >> guess; // prompt for another gamecout << "\nExcellent! You guessed the…arrow_forwardC++ help with this fixing code .cpp file #include<iostream>#include<string>#include<vector>#include"Food.h"using namespace std; class Nutrition{ private: string name; double Calories double Fat double Sugars double Protein double Sodium Nutrition(string n, double c, double f, double s, double p, double S): name(n), Calories(c), Fat(f),Sugars(s), Protein(p),Sodium(S){} food[Calories]= food[Fat]=food[Sugars]=food[Protein]=food[Sodium]=0; name = "";} Nutrition(string type, double calories, double fat, double sugar,double protein, double sodium){ food[Calories]= calories; food[Fat]=fat; food[Sugars]= sugar; food[Protein]=protein; food[Sodium]=sodium; name= type; } void setName(string type){ name = type; } void setCalories(double calories){ food [Calories]= calories; } void setFat(double fat){ food [Fat]= fat; } void setSugars(double sugar){ food [Sugars]= sugar; } void setProtein(double protein){ food [Protein]= protein; } void…arrow_forward
- // LargeSmall.cpp - This program calculates the largest and smallest of three integer values. #include <iostream> using namespace std; int main() { // This is the work done in the housekeeping() function // Declare and initialize variables here int largest; // Largest of the three values int smallest; // Smallest of the three values // Prompt the user to enter 3 integer values // Write assignment, add conditional statements here as appropriate // This is the work done in the endOfJob() function // Output largest and smallest number. cout << "The largest value is " << largest << endl; cout << "The smallest value is " << smallest << endl; return 0; }arrow_forward#include <iostream> #include <cmath> using namespace std; // declare functions void display_menu(); void convert_temp(); double to_celsius(double fahrenheit); double to_fahrenheit(double celsius); int main() { cout << "Convert Temperatures\n\n"; display_menu(); char again = 'y'; while (again == 'y') { convert_temp(); cout << "Convert another temperature? (y/n): "; cin >> again; cout << endl; } cout << "Bye!\n"; } // define functions void display_menu() { cout << "MENU\n" << "1. Fahrenheit to Celsius\n" << "2. Celsius to Fahrenheit\n\n"; } void convert_temp() { int option; cout << "Enter a menu option: "; cin >> option; double f = 0.0; double c = 0.0; switch (option) { case 1: cout << "Enter degrees Fahrenheit: "; cin >> f; c =…arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY