0

#include <stdio.h>

int x;

int y;

int a,b,c;

Not Yet Answered # I need help urgently on Arrays and functions

iamthwee 1,547 Ancient Dragon 5,243 Cool Nanu Rashakil Fol 978 Rashakil Fol 978 iamthwee 1,547 Rashakil Fol 978 soxers12 Ancient Dragon 5,243 Cool Nanu iamthwee 1,547 soxers12 Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...

0

#include <stdio.h>

int x;

int y;

int a,b,c;

0

#include <stdio.h>

int x;

int y;

int a,b,c;

Can you explain what you mean more clearly?

0

```
#include <stdio.h>
int x;
int y;
int a,b,c;
int main()
{
// put your code here
return 0;
}
```

0

Do u need a complete program for this I justcreated one for calculating the roots of QUADRATIC EQUATIONS.

Replyto this if u need one or anyone else will copyit and use it.

0

No, that's not what's being asked for. honeybleak, do you know how to do the calculation on paper?

0

That link has nothing to do with finding the global extremum, which is located at -b/2a. (If a = 0 then there is no global extremum.)

0

What does your avatar mean or represent Mr Rashakil? Remember the ancient dragon is no maths wizz kid :-)

0

I don't think it's a question of math, people just misinterpreted the problem (or had read the first misinterpretation of the problem). Why would I tell anybody what my avatar is?

0

you have to check the bounds. i.e. if someone inputs the range ( -1 , 2 ). you should check the following.

let f(x) = ax^2 + bx + c .

check f(-1), f(2) and f(-b/2a).

since this is a quadratic it can be assumed that a != 0.

if you are looking for mins and max those are the only possible places they can occur ( local extrema f(-1), f(2) ) and a global extrema f(-b/2a).

0

sorry, I thought you wanted to know how to calculate quadritic equation. Beyond that, I don't have a clue how to solve your problem.

0

This is the real one.

```
#include <stdlib.h>
#include<iostream.h>
#include<math.h>
#include<conio.h>
#include<dos.h>
void main()
{
restart:
;
clrscr();
cout<<"\n\n\t\t\tQuadratic Equation Calculator\n\t\t\t\tby ANIRUDH SANYAL"<<endl<<endl;
float a,b,c,x,y,d,d2,b2,a2,n1,n2,o;
a=b=c=d=x=y=a2=b2=d2=n1=n2=o=0;
char ch;
cout<<"\nEquation must be in the form of ax"<<(char)253<<"+bx+c=0"<<endl<<endl;
cout<<"\nPlease enter the value of co-efficient a: ";
cin>>a;
cout<<"\nPlease enter the value of co-efficient b: ";
cin>>b;
cout<<"\nPlease enter the value of co-efficient c: ";
cin>>c;
b2=pow(b,2);
o=4*a*c;
a2=2*a;
d=b2-o;
cout<<"\nThe Discriminent is "<<d;
if(o>b2)
{
cout<<"\n\nSorry....Discriminent is negative.Solution not possible";
goto breakend;
}
d2=sqrt(d);
n1=-b-d2;
n2=-b+d2;
x=n1/a2;
y=n2/a2;
cout<<"\n\nWait.....Input is being processed.....";
delay(500);
cout<<"\n\nThe ROOTS are \n x = "<<x<<" , "<<y;
breakend:
;
cout<<"\n\nDo you Want to continue?(y/n)...";
cin>>ch;
if(ch=='y'||ch=='Y')
goto restart;
else
cout<<"\n\nGood Bye...";
getch();
}
```

if u use this u will realy like it.

*Edited 3 Years Ago by mike_2000_17*: Fixed formatting

0

>Why would I tell anybody what my avatar is?

Why not? Do the dots represent the number of times you've been rejected?

:cheesy:

0

Hmm...

That seems like a good Quadratic Solver, but that wasn't the question. The question was minima and maxima. This should work

i haven't tested it thoroughly.

```
#include <iostream>
#include <stdlib.h>
using namespace std;
int main( int argc, char **argv ) {
double a, b, c, slope, lower, upper, f_lower, f_upper, f_slope;
double min, max;
if( argc != 6 ) {
cerr << argv[0] << " <a> <b> <c> <lower> <upper>\n";
exit(-1);
}
a = atof( argv[1] );
if( a == 0 ) {
cerr << "Since a is zero this is not a quadratic. Exiting.\n";
exit(-1);
}
b = atof( argv[2] );
c = atof( argv[3] );
lower = atof( argv[4] );
upper = atof( argv[5] );
slope = (-b / (2.0*a) );
f_lower = ( lower*lower*a + b*lower + c );
f_upper = ( upper*upper*a + b*upper + c );
f_slope = ( slope*slope*a + b*slope + c );
if( slope >= lower && slope <= upper ) {
if( f_slope <= f_lower && f_slope <= f_upper ) {
cout << "Min: x = " << slope << ", f(" << slope << ") = " << f_slope << " \n";
if( f_lower <= f_upper )
cout << "Max: x = " << upper << ", f(" << upper << ") = " << f_upper << " \n";
else
cout << "Max: x = " << lower << ", f(" << lower << ") = " << f_lower << " \n";
}
else {
if( f_lower <= f_upper )
cout << "Min: x = " << lower << ", f(" << lower << ") = " << f_lower << " \n";
else
cout << "Min: x = " << upper << ", f(" << upper << ") = " << f_upper << " \n";
cout << "Max: x = " << slope << ", f(" << slope << ") = " << f_slope << " \n";
}
}
else {
cout << "The extrema is out of range so the minimum and maximum \n";
cout << " values occur on the boundaries\n\n";
if( f_lower <= f_upper ) {
cout << "Min: x = " << lower << ", f(" << lower << ") = " << f_lower << " \n";
cout << "Max: x = " << upper << ", f(" << upper << ") = " << f_upper << " \n";
}
else {
cout << "Min: x = " << upper << ", f(" << upper << ") = " << f_upper << " \n";
cout << "Max: x = " << lower << ", f(" << lower << ") = " << f_lower << " \n";
}
}
}
```

This article has been dead for over six months. Start a new discussion instead.

Recommended Articles

Hi. so this is actually a continuation from another question of mineHere but i was advised to start a new thread as the original question was already answered.

This is the result of previous question answered :

code for the listbox - datagridview interaction

At the top of the code ...

the function that I created to find the ...