I have no idea where to start with this program. Any help would be appreciated.
ID: 3569426 • Letter: I
Question
I have no idea where to start with this program. Any help would be appreciated. It is for a c++ program.
The quadratic formula for computing the square-roots of a quadratic equation is:
This formula uses exponentiation (power function) to calculate the positive and negative
square roots of the equation. Write a class called QuadraticEquation with private member
variables a,b and c, four public member functions called input() that asks the user for
values of a,b and c; output() that displays the two root values; getPositiveRoot() and
getNegativeRoot() that return the result of the quadratic formula accordingly. In addition,
define a private member function called checkValues(), which will be called in input(), that
will display an error message on screen if a is 0 or b
2
-4ac<0, and will exit the program.
Write a complete program. (
Explanation / Answer
#include<stdio.h>
#include<conio.h>
void main() {
struct student {
char name[30];
char sex;
int rollno;
float percentage;
};
union details {
struct student st;
};
union details set;
printf("Enter details:");
printf(" Enter name : ");
scanf("%s", set.st.name);
printf(" Enter roll no : ");
scanf("%d", &set.st.rollno);
flushall();
printf(" Enter sex : ");
scanf("%c", &set.st.sex);
printf(" Enter percentage :");
scanf("%f", &set.st.percentage);
printf(" The student details are : ");
printf(" ame : %s", set.st.name);
printf(" Rollno : %d", set.st.rollno);
printf(" Sex : %c", set.st.sex);
printf(" Percentage : %f", set.st.percentage);
getch();