Click here to Skip to main content
15,925,206 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Read sector Pin
Y_R15-Mar-05 9:14
Y_R15-Mar-05 9:14 
Generalwin 32 API virtual memory Pin
mpapeo14-Mar-05 11:53
mpapeo14-Mar-05 11:53 
GeneralLooking to simplify my life Pin
Aggrav8d14-Mar-05 11:30
Aggrav8d14-Mar-05 11:30 
GeneralRe: Looking to simplify my life Pin
bobi_zcl14-Mar-05 14:11
bobi_zcl14-Mar-05 14:11 
GeneralCPropertyPage Wizard Style.. Should be easy.. Pin
RobJones14-Mar-05 11:26
RobJones14-Mar-05 11:26 
GeneralRe: CPropertyPage Wizard Style.. Should be easy.. Pin
Ralph Wetzel14-Mar-05 11:49
Ralph Wetzel14-Mar-05 11:49 
GeneralRe: CPropertyPage Wizard Style.. Should be easy.. Pin
RobJones14-Mar-05 12:14
RobJones14-Mar-05 12:14 
GeneralText color of VS2003 output window Pin
Ravi Bhavnani14-Mar-05 10:46
professionalRavi Bhavnani14-Mar-05 10:46 
Generalvisual c++ .net 2003 Pin
jogodo14-Mar-05 10:00
jogodo14-Mar-05 10:00 
GeneralRe: visual c++ .net 2003 Pin
Christian Graus14-Mar-05 16:29
protectorChristian Graus14-Mar-05 16:29 
GeneralGetting total network traffic Pin
vapz14-Mar-05 9:57
vapz14-Mar-05 9:57 
GeneralBold text in menu Pin
qwert8510314-Mar-05 9:08
qwert8510314-Mar-05 9:08 
GeneralRe: Bold text in menu Pin
Graham Bradshaw14-Mar-05 12:30
Graham Bradshaw14-Mar-05 12:30 
GeneralCreateProcess Questions Pin
kyensen14-Mar-05 8:35
kyensen14-Mar-05 8:35 
GeneralRe: CreateProcess Questions Pin
Peter Weyzen14-Mar-05 8:54
Peter Weyzen14-Mar-05 8:54 
GeneralMessages of parent windows Pin
r3dqu33n14-Mar-05 8:00
r3dqu33n14-Mar-05 8:00 
GeneralRe: Messages of parent windows Pin
namaskaaram14-Mar-05 19:42
namaskaaram14-Mar-05 19:42 
GeneralRe: Messages of parent windows Pin
r3dqu33n15-Mar-05 1:02
r3dqu33n15-Mar-05 1:02 
GeneralRe: Messages of parent windows Pin
namaskaaram15-Mar-05 2:48
namaskaaram15-Mar-05 2:48 
Generalsetup project Pin
trupgmtuf14-Mar-05 7:20
susstrupgmtuf14-Mar-05 7:20 
GeneralCrash in InternetErrorDlg()! Help! Pin
Nickmatic14-Mar-05 7:00
Nickmatic14-Mar-05 7:00 
Generalquadratic equations Pin
gyrvwrzp14-Mar-05 6:59
gyrvwrzp14-Mar-05 6:59 
ive been having trouble with pointers in this program. just been learning about them and putting it into practice. ive commented in the code below where im getting the error, im getting a syntax error for where i thought i could use the pointer as i could if i were using what i am pointing to, strange im getting that errorSigh | :sigh: . the program is supposed to read the coeffients and signs of three variables to solve a quatratic equation. im trying to read the variables onto a stack then have the results output, by using recurssion twice. would really appreciate your helpCool | :cool:


#include <iostream>
#include <iomanip>
#include <conio.h>
#include <string>
#include <math.h>
#include "console.h"
using namespace std;

bool quadrt( float, float, float, float*, float* );
void quadr( void );
void quadrr( void );

static float r, x, y, z, x1, x2, *co;
char s, j, k, l;
int p = 9, m = 0, n = 0, i;

string header = "*** Quadratic equations ***\n\n",
line( 30, '-' );

void quadEquation()
{

cout << header << line << "\nEnter enter coefficients a, b, c with signs\n" << endl;

quadrr();

getch();
return;

}

void quadrr( void )
{
m++;
co = &x;

for( i = 1; i <= 3; i++ )
{
do
cin >> *co;
while
*co == false; // if input is not a valid floating point number
// error C2059: syntax error : '*'

if( -*co >= 0 ) // if input is negative
s = '-';
else
s = '+';

switch( i )
{
case 1: co = &y; // point to y address
j = s;
break;
case 2: co = &z;
k = s;
break;
case 3: l = s;
break;
}
}
switch( getch() )
{
case 27: goto end;
default: break;
}

if( m == 1 )
cout << "Quadratic Equations Solutions\n" << line << endl << endl;
quadrr();
end:
quadr();

}

void quadr( void )
{
n++;

if( x != 0 )
cout << j << ' ' << x << "x^2 ";
if( y != 0 )
cout << k << ' ' << y << "x ";
if( z != 0 )
cout << l << ' ' << z;
cout << " = 0 ";

p += 1;

setCursor( p, 30 );

if( quadrt( x, y, z, &x1, &x2 ) )
cout << "x1 = " << x1 << ',' << " x2 = " << x2 << endl;
else
cout << "no solution exists" << endl;

if( n == m ) return;
quadr();
}

bool quadrt( float a, float b, float c, float *n1, float *n2 )
{
r = ( b * b - 4 * a * c );
if( r >= 0 )
{
*n1 = ( -b + sqrt(r) ) / ( 2 * a );
*n2 = ( -b - sqrt(r) ) / ( 2 * a );
return true;
}
else return false;
}
GeneralRe: quadratic equations Pin
David Crow14-Mar-05 8:21
David Crow14-Mar-05 8:21 
GeneralShoping Cart Pin
shahidalikhan14-Mar-05 6:55
shahidalikhan14-Mar-05 6:55 
GeneralRe: Shoping Cart Pin
RobJones14-Mar-05 11:33
RobJones14-Mar-05 11:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.