Mail Archives: djgpp/2007/09/18/10:45:28
--Boundary_(ID_x2432Oakb0QQ2yMqK5vhqA)
Content-type: text/plain; charset=us-ascii; format=flowed
Content-transfer-encoding: 7BIT
Dear List -
Can someone please help me with the following C code.  It aborts with 
code 1.  My apologies for the length of the code.
Ethan
=============
/*
  * A routine to calculate the BMI.  Will perform the calculation 
with metric or
  * English input.  Calculates the BMI both pregravid and gravid.
  */
#include <stdio.h>
#include <conio.h>
#include <ctype.h>
#define BOLD   "\x1B[1m"
#define NORMAL "\x1B[0M"
void enter_header(int *p_xbmig, int *p_xbmipg, int *p_xpoundsg,
     int *p_xpoundspg, int *p_xfeet, int *p_xinches, int 
*p_elec_spac, int *p_amp_gain,
     int y1stline, int y2ndline, int y3rdline);
void  display_results(int inches_display, float pounds_pg, float amp_gain,
       float pounds_g, int feet_display, int ibmi_pg, int ibmi_g, 
float elec_spac,
       int xbmig, int xbmipg, int xpoundsg, int xpoundspg, int xfeet, 
int xinches,
       int xelec_spac, int xamp_gain, int y1stline, int y2ndline, int 
y3rdline);
static int ibmi_pg, ibmi_g;
static float meters, inches, pounds, pounds_pg, pounds_g, kg, feet, 
bmi, bmi_pg;
static float bmi_g, elec_spac, amp_gain;
int xamp_gain;
/*
  * The calculating function.  Takes input in meters/kg or 
feet-inches/pounds, converts
  * from metric to english, and performs the calculation.
  */
int main(void)
{
     int x, y, key, ibmi, valid, not_correct, not_valid;
     int iter;
     char choice, choice2;
     int xbmig, xbmipg, xpoundsg, xpoundspg, xfeet, xinches, xelec_spac;
     int /*xamp_gain,*/ ifeet_display, inches_display, feet_display;
     int y1stline, y2ndline, y3rdline, spacing, gain;
     int *p_xbmig, *p_xbmipg, *p_xpoundsg, *p_xpoundspg, *p_xfeet, *p_xinches;
     int *p_xelec_spac, *p_xamp_gain, *p_y1stline, *p_y2ndline, *p_y3rdline;
/*Initialize pointers*/
     p_xbmig      = &xbmig;
     p_xbmipg     = &xbmipg;
     p_xpoundsg   = &xpoundsg;
     p_xpoundspg  = &xpoundspg;
     p_xfeet      = &xfeet;
     p_xinches    = &xinches;
     p_xelec_spac = &xelec_spac;
     p_xamp_gain  = &xamp_gain;
/*    p_y1stline   = &y1stline;
     p_y2ndline   = &y2ndline;
     p_y3rdline   = &y3rdline;*/
     inches    = 0.0;
     meters    = 0.0;
     kg        = 0.0;
     pounds_pg = 0.0;
     pounds_g  = 0.0;
     feet      = 0.0;
     bmi_pg    = 0.0;
     bmi_g     = 0.0;
     elec_spac = 0.0;
     amp_gain  = 0.0;
     inches_display = 0;
     feet_display   = 0;
     ibmi_pg        = 0;
     ibmi_g         = 0;
     y1stline   =  6;
     y2ndline   =  8;
     y3rdline   =  10;
/* Set up Header*/
     enter_header(p_xbmig, p_xbmipg, p_xpoundsg, p_xpoundspg,
           p_xfeet, p_xinches, p_xelec_spac, p_xamp_gain, y1stline,
           y2ndline,  y3rdline);
/* Enter Height */
     gotoxy(1,18);
     not_correct = 1;
     while(not_correct)
     {
         printf("\nEnter M for metric or E for English:  ");
         y = wherey();
         choice = getche();
         choice = toupper(choice);
         if (choice == 'M' || choice  == 'E')
             not_correct = 0;
         else
         {
                 printf("\a");
                 printf("\nERROR -- Valid answers are M or E -- Press 
any key to continue...");
                 key = getch();
                 gotoxy(1,y-1);
         }
     }
     switch(choice)
     {
     case 'M':
         not_valid = 1;
         while(not_valid)
         {
             gotoxy(1,18);
             y = wherey();
             printf("\nEnter height in meters:  ");
             clreol();
             valid =  scanf("%f", &meters);
             while (getchar() != '\n')
                 continue;
             if(valid)
                 not_valid = 0;
             if(!valid)
             {
                 printf("\a");
                 printf("ERROR -- NUMERIC ENTRIES ONLY!! -- Press any 
key to continue...");
                 key = getch();
             }
         }
         clreol();
         inches = meters*39.37;
         feet_display = (int)inches/12;
         inches_display = (int)inches%12;
         display_results(inches_display, pounds_pg, pounds_g, 
feet_display, ibmi_pg, ibmi_g, amp_gain,
             elec_spac, xbmig, xbmipg, xpoundsg, xpoundspg, xfeet, xinches,
             xelec_spac, xamp_gain, y1stline, y2ndline, y3rdline);
         break;
     case 'E':
         not_valid = 1;
         while(not_valid)
         {
             gotoxy(1,18);
             y = wherey();
             printf("\nEnter height in feet & inches - FEET: ");
             clreol();
             valid =  scanf("%f", &feet);
             while (getchar() != '\n')
                 continue;
             if(valid)
                 not_valid = 0;
             if(!valid)
             {
                 printf("\a");
                 printf("ERROR -- NUMERIC ENTRIES ONLY!! -- Press any 
key to continue...");
                 key = getch();
             }
         }
         gotoxy(1, y+2);
         clreol();
         not_valid = 1;
         while(not_valid)
         {
             gotoxy(1,18);
             y = wherey();
             gotoxy(1, y+2);
             clreol();
             printf("Enter height in feet & inches - INCHES: ");
             clreol();
             valid =  scanf("%f", &inches);
             while (getchar() != '\n')
                 continue;
             if(valid)
                 not_valid = 0;
             if(!valid)
             {
                 printf("\a");
                 printf("ERROR -- NUMERIC ENTRIES ONLY!! -- Press any 
key to continue...");
                 key = getch();
             }
         }
         gotoxy(1, y+3);
         printf("\n#1");
         clreol();
         printf("\n#2");
         inches_display = (int)inches;
         printf("\n#3");
         inches = feet*12.0 + inches;
         printf("\n#4");
         feet_display = (int)feet;
         printf("\n#5");
         display_results(inches_display, pounds_pg, pounds_g, 
feet_display, ibmi_pg, ibmi_g, amp_gain,
             elec_spac, xbmig, xbmipg, xpoundsg, xpoundspg, xfeet, xinches,
             xelec_spac, xamp_gain, y1stline, y2ndline, y3rdline);
     } /*End Case */
/*
  * Enter weights, pregavid and gravid and calculate BMI
  * Iterate twice, and use switch on iteration to determine if the weight
  * gravid or pregravid for BMI gravid and pregravid
  */
     for(iter = 1; iter < 3; iter++)
     {
         not_correct = 1;
         while(not_correct)
         {
             gotoxy(1,18);
             clreol();
             y = wherey();
             printf("\nEnter M for metric or E for English:  ");
             choice2 = getche();
             choice2 = toupper(choice2);
             if (choice2 == 'M' || choice2 == 'E')
                 not_correct = 0;
             else
             {
                 printf("\a");
                 printf("\nERROR -- Valid answers are M or E -- Press 
any key to continue...");
                 key = getch();
                 gotoxy(1,y-1);
             }
             switch(choice2)
             {
             case 'M':
             gotoxy(1,18);
             clreol();
             y = wherey();
             gotoxy(1, y+1);
             clreol();
             gotoxy(1,18);
             not_valid = 1;
             while(not_valid)
             {
                 gotoxy(1, y+1);
                 if(iter == 1)
                     printf("Enter PreGravid weight in Kg:  ");
                 else
                     printf("Enter Gravid weight in Kg:  ");
                 clreol();
                 valid = scanf("%f", &kg);
                 while (getchar() != '\n')
                     continue;
                 if (valid)
                         not_valid = 0;
                     if(!valid)
                     {
                         printf("\a");
                         printf("ERROR -- NUMERIC ENTRIES ONLY!! -- 
Press any key to continue...");
                         key = getch();
                     }
             }
                 gotoxy(1, y+2);
                 clreol();
                 pounds = kg*2.204;
                 if(iter == 1)
                     pounds_pg = pounds;
                 else
                     pounds_g  = pounds;
                 display_results(inches_display, pounds_pg, pounds_g, 
feet_display, ibmi_pg, ibmi_g, amp_gain,
                     elec_spac, xbmig, xbmipg, xpoundsg, xpoundspg, 
xfeet, xinches,
                     xelec_spac, xamp_gain, y1stline, y2ndline, y3rdline);
         break; /* End Case M */
                 case 'E':
                 not_valid = 1;
                 while(not_valid)
                 {
                     gotoxy(1,18);
                     y = wherey();
                     clreol();
                     gotoxy(1, y+1);
                     clreol();
                     gotoxy(1,y+2);
                     clreol();
                     gotoxy(1,18);
                     if(iter == 1)
                         printf("Enter PreGravid weight in Pounds:  ");
                     else
                         printf("Enter Gravid weight in Pounds:  ");
                     clreol();
                     valid =  scanf("%f", £s);
                     while (getchar() != '\n')
                         continue;
                     if (valid)
                        not_valid = 0;
                     if(!valid)
                     {
                         printf("\a");
                         printf("ERROR -- NUMERIC ENTRIES ONLY!! -- 
Press any key to continue...");
                         key = getch();
                     }
                     gotoxy(1, y+2);
                 if(iter == 1)
                     pounds_pg = pounds;
                 else
                     pounds_g  = pounds;
                 clreol();
                 printf("\n%s","#2");
                 display_results(inches_display, pounds_pg, pounds_g, 
feet_display, ibmi_pg, ibmi_g, amp_gain,
                     elec_spac, xbmig, xbmipg, xpoundsg, xpoundspg, 
xfeet, xinches,
                     xelec_spac, xamp_gain, y1stline, y2ndline, y3rdline);
            }
         break;
         }
                 if(iter == 1)
                 {
                     bmi_pg = pounds_pg*703.07/(inches*inches);
                     ibmi_pg = (int)bmi_pg;
                     if(bmi_pg - ibmi_pg > 0.5)
                         ibmi_pg = ibmi_pg +1;
                 }
                 else
                 {
                     bmi_g  = pounds_g*703.07/(inches*inches);
                     ibmi_g = (int)bmi_g;
                     if(bmi_g - ibmi_g > 0.5)
                         ibmi_g = ibmi_g +1;
                 }
                 display_results(inches_display, pounds_pg, pounds_g, 
feet_display, ibmi_pg, ibmi_g, amp_gain,
                     elec_spac, xbmig, xbmipg, xpoundsg, xpoundspg, 
xfeet, xinches,
                     xelec_spac, xamp_gain, y1stline, y2ndline, y3rdline);
            }
            iter++;
         } /* End Iteration */
}
/*
  * Enter Header - a routine that writes the header for all the values and
  * and sets up the positions for all the variables
  */
/*void enter_header(int *p_xbmig, int *p_xbmipg, int *p_xpoundsg,
     int *p_xpoundspg, int *p_xfeet, int *p_xinches, int *p_xelec_spac,
     int *p_xamp_gain,int *p_y1stline, int *p_y2ndline, int *p_y3rdline)*/
void enter_header(int *p_xbmig, int *p_xbmipg, int *p_xpoundsg,
     int *p_xpoundspg, int *p_xfeet, int *p_xinches, int 
*p_xelec_spac, int *p_xamp_gain,
     int y1stline, int y2ndline, int y3rdline)
{
     char dummy[] = "****************************************";
/*    int y1stline, y2ndline, y3rdline;*/
     clrscr();
/*    gotoxy(38,3);
     printf("BMI");*/
/*    *p_y1stline = 7;
     *p_y2ndline = 9;
     *p_y3rdline = 11;
     y1stline = *p_y1stline;
     y2ndline = *p_y2ndline;
     y3rdline = *p_y3rdline;*/
     gotoxy(1,y1stline);
     printf("Hgt (ft): ");
     *p_xfeet = wherex();
     gotoxy(15,y1stline);
     printf("Hgt (in): ");
     *p_xinches = wherex();
     gotoxy(35,y1stline);
     printf("Wgt pg (lbs):  ");
     *p_xpoundspg = wherex();
     gotoxy(55,y1stline);
     printf("Wgt gvd (lbs):  ");
     *p_xpoundsg = wherex();
     gotoxy(1,y2ndline);
     printf("BMI pg:  ");
     *p_xbmipg = wherex();
     gotoxy(40, y2ndline);
     printf("BMI gvd:  ");
     *p_xbmig = wherex();
     gotoxy(1, y3rdline);
     printf("Elec Spac (cm):  ");
     *p_xelec_spac = wherex();
     gotoxy(40, y3rdline);
     printf("Amp Gain:  ");
     *p_xamp_gain = wherex();
     gotoxy(20, y3rdline + 2);
     printf("%s\n\n", dummy);
}
/*
  * Display Results - a routine to enter the results into the header created
  * with Enter Header
  */
void  display_results(int inches_display, float pounds_pg, float amp_gain,
       float pounds_g, int feet_display, int ibmi_pg, int ibmi_g, 
float elec_spac,
       int xbmig, int xbmipg, int xpoundsg, int xpoundspg, int xfeet, 
int xinches,
       int xelec_spac, int xamp_gain, int y1stline, int y2ndline, int y3rdline)
{
     gotoxy(xfeet,y1stline);
     printf("%d", feet_display);
     gotoxy(xinches,y1stline);
     printf("%d", inches_display);
     gotoxy(xpoundspg,y1stline);
     printf("%d", (int)pounds_pg);
     gotoxy(xpoundsg,y1stline);
     printf("%d", (int)pounds_g);
     gotoxy(xbmipg,y2ndline);
     printf("%d", ibmi_pg);
     gotoxy(xbmig,y2ndline);
     printf("%d", ibmi_g);
     gotoxy(xelec_spac,y3rdline);
     printf("%d", (int)elec_spac);
     gotoxy(xamp_gain,y3rdline);
     printf("%d", (int)amp_gain);
}
     fspacing = (float)spacing;
     fgain = fspacing/3.0 + 2.0;
     gain = (int)fgain;
     if(fgain - gain > 0.5)
         gain = gain +1;
     return gain;
}
====== 
--Boundary_(ID_x2432Oakb0QQ2yMqK5vhqA)
Content-type: text/html; charset=us-ascii
Content-transfer-encoding: 7BIT
<html>
<body>
Dear List -<br><br>
Can someone please help me with the following C code.  It aborts
with code 1.  My apologies for the length of the code.<br><br>
Ethan<br><br>
=============<br>
<font face="Courier New, Courier">/*<br>
 * A routine to calculate the BMI.  Will perform the
calculation with metric or<br>
 * English input.  Calculates the BMI both pregravid and
gravid.  <br>
 */<br><br>
#include <stdio.h><br>
#include <conio.h><br>
#include <ctype.h><br><br>
#define BOLD   "\x1B[1m"<br>
#define NORMAL "\x1B[0M"<br><br>
void enter_header(int *p_xbmig, int *p_xbmipg, int *p_xpoundsg,<br>
    int *p_xpoundspg, int *p_xfeet, int *p_xinches, int
*p_elec_spac, int *p_amp_gain,<br>
    int y1stline, int y2ndline, int y3rdline);<br><br>
<br>
void  display_results(int inches_display, float pounds_pg, float
amp_gain,<br>
      float pounds_g, int feet_display, int
ibmi_pg, int ibmi_g, float elec_spac,<br>
      int xbmig, int xbmipg, int xpoundsg, int
xpoundspg, int xfeet, int xinches,<br>
      int xelec_spac, int xamp_gain, int
y1stline, int y2ndline, int y3rdline);<br><br>
<br>
static int ibmi_pg, ibmi_g;<br>
static float meters, inches, pounds, pounds_pg, pounds_g, kg, feet, bmi,
bmi_pg;<br>
static float bmi_g, elec_spac, amp_gain;<br>
int xamp_gain;<br><br>
<br><br>
<br>
/*<br>
 * The calculating function.  Takes input in meters/kg or
feet-inches/pounds, converts<br>
 * from metric to english, and performs the calculation.<br>
 */<br>
 <br>
int main(void)<br>
{<br>
    int x, y, key, ibmi, valid, not_correct,
not_valid;<br>
    int iter;<br>
    char choice, choice2;<br>
    int xbmig, xbmipg, xpoundsg, xpoundspg, xfeet,
xinches, xelec_spac;<br>
    int /*xamp_gain,*/ ifeet_display, inches_display,
feet_display;<br>
    int y1stline, y2ndline, y3rdline, spacing, gain;<br>
    int *p_xbmig, *p_xbmipg, *p_xpoundsg, *p_xpoundspg,
*p_xfeet, *p_xinches;<br>
    int *p_xelec_spac, *p_xamp_gain, *p_y1stline,
*p_y2ndline, *p_y3rdline;<br><br>
<br>
/*Initialize pointers*/<br><br>
    p_xbmig      =
&xbmig;<br>
    p_xbmipg     = &xbmipg;<br>
    p_xpoundsg   = &xpoundsg;<br>
    p_xpoundspg  = &xpoundspg;<br>
    p_xfeet      =
&xfeet;<br>
    p_xinches    = &xinches;<br>
    p_xelec_spac = &xelec_spac;<br>
    p_xamp_gain  = &xamp_gain;<br>
/*    p_y1stline   = &y1stline;<br>
    p_y2ndline   = &y2ndline;<br>
    p_y3rdline   = &y3rdline;*/<br>
    <br>
    inches    = 0.0;<br>
    meters    = 0.0;<br>
    kg        =
0.0;<br>
    pounds_pg = 0.0;<br>
    pounds_g  = 0.0;<br>
    feet      = 0.0;<br>
    bmi_pg    =
0.0;             
<br>
    bmi_g     = 0.0;<br>
    elec_spac = 0.0;<br>
    amp_gain  = 0.0;<br>
    inches_display = 0;<br>
    feet_display   = 0;<br>
    ibmi_pg        =
0;<br>
    ibmi_g        
= 0;<br>
    y1stline   =  6;<br>
    y2ndline   =  8;<br>
    y3rdline   =  10;<br>
    <br><br>
/* Set up Header*/<br><br>
    enter_header(p_xbmig, p_xbmipg, p_xpoundsg,
p_xpoundspg,<br>
          p_xfeet,
p_xinches, p_xelec_spac, p_xamp_gain, y1stline,<br>
          y2ndline, 
y3rdline);<br><br>
<br>
/* Enter Height */<br><br>
    gotoxy(1,18);<br>
    not_correct = 1;<br>
    while(not_correct)<br>
    {<br>
        printf("\nEnter M for
metric or E for English:  ");<br>
        y = wherey();<br>
        choice = getche();<br>
        choice = toupper(choice);<br>
        if (choice == 'M' ||
choice  == 'E')<br>
           
not_correct = 0;<br>
        else<br>
        {<br>
       
<x-tab>        </x-tab>
printf("\a");<br>
<x-tab>        </x-tab>
        printf("\nERROR -- Valid
answers are M or E -- Press any key to continue...");<br>
               
key = getch();<br>
       
<x-tab>        </x-tab>
gotoxy(1,y-1);<br>
        }<br><br>
    }<br><br>
    switch(choice)<br>
    {<br>
    case 'M':<br>
        not_valid = 1;<br>
        while(not_valid)<br>
        {<br>
           
gotoxy(1,18);<br>
            y =
wherey();<br>
           
printf("\nEnter height in meters:  ");<br>
           
clreol();<br>
            valid
=  scanf("%f", &meters);<br>
            while
(getchar() != '\n')<br>
               
continue;<br>
           
if(valid)<br>
               
not_valid = 0;<br>
           
if(!valid)<br>
            {<br>
               
printf("\a");<br>
               
printf("ERROR -- NUMERIC ENTRIES ONLY!! -- Press any key to
continue...");<br>
               
key = getch();<br>
            }<br>
        }<br><br>
        clreol();<br>
        inches = meters*39.37;<br>
        feet_display =
(int)inches/12;<br>
        inches_display =
(int)inches%12;<br><br>
       
display_results(inches_display, pounds_pg, pounds_g, feet_display,
ibmi_pg, ibmi_g, amp_gain,<br>
           
elec_spac, xbmig, xbmipg, xpoundsg, xpoundspg, xfeet, xinches,<br>
           
xelec_spac, xamp_gain, y1stline, y2ndline, y3rdline);<br><br>
        break;<br><br>
    case 'E':<br>
        not_valid = 1;<br>
        while(not_valid)<br>
        {<br>
           
gotoxy(1,18);<br>
            y =
wherey();<br>
           
printf("\nEnter height in feet & inches - FEET: ");<br>
           
clreol();<br>
            valid
=  scanf("%f", &feet);<br>
            while
(getchar() != '\n')<br>
               
continue;<br>
           
if(valid)<br>
               
not_valid = 0;<br>
           
if(!valid)<br>
            {<br>
               
printf("\a");<br>
               
printf("ERROR -- NUMERIC ENTRIES ONLY!! -- Press any key to
continue...");<br>
               
key = getch();<br>
            }<br>
        }<br><br>
        gotoxy(1, y+2);<br>
        clreol();<br><br>
        not_valid = 1;<br>
        while(not_valid)<br>
        {<br>
           
gotoxy(1,18);<br>
            y =
wherey();<br>
           
gotoxy(1, y+2);<br>
           
clreol();<br>
           
printf("Enter height in feet & inches - INCHES: ");<br>
           
clreol();<br>
            valid
=  scanf("%f", &inches);<br>
            while
(getchar() != '\n')<br>
               
continue;<br>
           
if(valid)<br>
               
not_valid = 0;<br>
           
if(!valid)<br>
            {<br>
               
printf("\a");<br>
               
printf("ERROR -- NUMERIC ENTRIES ONLY!! -- Press any key to
continue...");<br>
               
key = getch();<br>
            }<br>
        }<br>
        gotoxy(1, y+3);<br>
        printf("\n#1");<br>
        clreol();<br>
        printf("\n#2");<br>
        inches_display =
(int)inches;<br>
        printf("\n#3");<br>
        inches = feet*12.0 +
inches;<br>
        printf("\n#4");<br>
        feet_display = (int)feet;<br>
       
printf("\n#5");<br><br>
       
display_results(inches_display, pounds_pg, pounds_g, feet_display,
ibmi_pg, ibmi_g, amp_gain,<br>
           
elec_spac, xbmig, xbmipg, xpoundsg, xpoundspg, xfeet, xinches,<br>
           
xelec_spac, xamp_gain, y1stline, y2ndline, y3rdline);<br>
    } /*End Case */<br><br>
/*<br>
 * Enter weights, pregavid and gravid and calculate BMI<br>
 * Iterate twice, and use switch on iteration to determine if the
weight<br>
 * gravid or pregravid for BMI gravid and pregravid<br>
 */<br><br>
    for(iter = 1; iter < 3; iter++)<br>
    {<br>
        not_correct = 1;<br>
        while(not_correct)<br>
        {<br>
           
gotoxy(1,18);<br>
           
clreol();<br>
            y =
wherey();<br>
           
printf("\nEnter M for metric or E for English:  ");<br>
           
choice2 = getche();<br>
           
choice2 = toupper(choice2);<br>
            if
(choice2 == 'M' || choice2 == 'E')<br>
               
not_correct = 0;<br>
           
else<br>
            {<br>
               
printf("\a");<br>
               
printf("\nERROR -- Valid answers are M or E -- Press any key to
continue...");<br>
               
key = getch();<br>
               
gotoxy(1,y-1);<br>
           
}<br><br>
           
switch(choice2)<br>
            {<br>
            case
'M':<br>
           
gotoxy(1,18);<br>
           
clreol();<br>
            y =
wherey();<br>
           
gotoxy(1, y+1);<br>
           
clreol();<br>
           
gotoxy(1,18);<br>
           
not_valid = 1;<br>
           
while(not_valid)<br>
            {<br>
               
gotoxy(1, y+1);<br>
               
if(iter == 1)<br>
                   
printf("Enter PreGravid weight in Kg:  ");<br>
               
else<br>
                   
printf("Enter Gravid weight in Kg:  ");<br>
               
clreol();<br>
               
valid = scanf("%f", &kg);<br>
               
while (getchar() != '\n')<br>
                   
continue;<br>
               
if (valid)<br>
                       
not_valid = 0;<br>
                   
if(!valid)<br>
                   
{<br>
                       
printf("\a");<br>
                       
printf("ERROR -- NUMERIC ENTRIES ONLY!! -- Press any key to
continue...");<br>
                       
key = getch();<br>
                   
}<br>
            }<br>
               
gotoxy(1, y+2);<br>
               
clreol();<br>
               
pounds = kg*2.204;<br>
               
if(iter == 1)<br>
                   
pounds_pg = pounds;<br>
               
else<br>
                   
pounds_g  = pounds;<br>
        <br>
        <br>
               
display_results(inches_display, pounds_pg, pounds_g, feet_display,
ibmi_pg, ibmi_g, amp_gain,<br>
                   
elec_spac, xbmig, xbmipg, xpoundsg, xpoundspg, xfeet, xinches,<br>
                   
xelec_spac, xamp_gain, y1stline, y2ndline, y3rdline);<br><br>
        break; /* End Case M */<br>
               
case 'E':<br>
               
not_valid = 1;<br>
               
while(not_valid)<br>
               
{<br>
                   
gotoxy(1,18);<br>
                   
y = wherey();<br>
                   
clreol();<br>
                   
gotoxy(1, y+1);<br>
                   
clreol();<br>
                   
gotoxy(1,y+2);<br>
                   
clreol();<br>
                   
gotoxy(1,18);<br>
                   
if(iter == 1)<br>
                       
printf("Enter PreGravid weight in Pounds:  ");<br>
                   
else<br>
                       
printf("Enter Gravid weight in Pounds:  ");<br>
                   
clreol();<br>
                   
valid =  scanf("%f", &pounds);<br>
                   
while (getchar() != '\n')<br>
                       
continue;<br>
                   
if (valid)<br>
                      
not_valid = 0;<br>
                   
if(!valid)<br>
                   
{<br>
                       
printf("\a");<br>
                       
printf("ERROR -- NUMERIC ENTRIES ONLY!! -- Press any key to
continue...");<br>
                       
key = getch();<br>
                   
}<br>
                   
gotoxy(1, y+2);<br>
               
if(iter == 1)<br>
                   
pounds_pg = pounds;<br>
               
else<br>
                   
pounds_g  = pounds;<br><br>
               
clreol();<br>
               
printf("\n%s","#2");<br>
               
<br>
               
display_results(inches_display, pounds_pg, pounds_g, feet_display,
ibmi_pg, ibmi_g, amp_gain,<br>
                   
elec_spac, xbmig, xbmipg, xpoundsg, xpoundspg, xfeet, xinches,<br>
                   
xelec_spac, xamp_gain, y1stline, y2ndline, y3rdline);<br><br>
           }<br><br>
        break;<br>
        }<br>
               
if(iter == 1)<br>
               
{<br>
                   
bmi_pg = pounds_pg*703.07/(inches*inches);<br>
                   
ibmi_pg = (int)bmi_pg;<br>
                   
if(bmi_pg - ibmi_pg > 0.5)<br>
                       
ibmi_pg = ibmi_pg +1;<br>
               
}<br><br>
               
else<br>
               
{<br>
                   
bmi_g  = pounds_g*703.07/(inches*inches);<br>
                   
ibmi_g = (int)bmi_g;<br>
                   
if(bmi_g - ibmi_g > 0.5)<br>
                       
ibmi_g = ibmi_g +1;<br>
               
}<br>
               
display_results(inches_display, pounds_pg, pounds_g, feet_display,
ibmi_pg, ibmi_g, amp_gain,<br>
                   
elec_spac, xbmig, xbmipg, xpoundsg, xpoundspg, xfeet, xinches,<br>
                   
xelec_spac, xamp_gain, y1stline, y2ndline, y3rdline);<br><br>
           }<br>
           iter++;<br>
        } /* End Iteration */<br><br>
        <br><br>
<br>
}<br><br>
/*<br>
 * Enter Header - a routine that writes the header for all the
values and<br>
 * and sets up the positions for all the variables<br>
 */<br><br>
/*void enter_header(int *p_xbmig, int *p_xbmipg, int *p_xpoundsg,<br>
    int *p_xpoundspg, int *p_xfeet, int *p_xinches, int
*p_xelec_spac, <br>
    int *p_xamp_gain,int *p_y1stline, int *p_y2ndline, int
*p_y3rdline)*/<br><br>
void enter_header(int *p_xbmig, int *p_xbmipg, int *p_xpoundsg,<br>
    int *p_xpoundspg, int *p_xfeet, int *p_xinches, int
*p_xelec_spac, int *p_xamp_gain,<br>
    int y1stline, int y2ndline, int y3rdline)<br><br>
<br>
{<br><br>
    char dummy[] =
"****************************************";<br>
/*    int y1stline, y2ndline, y3rdline;*/<br><br>
    clrscr();<br><br>
/*    gotoxy(38,3);<br>
    printf("BMI");*/<br>
    <br>
/*    *p_y1stline = 7;<br>
    *p_y2ndline = 9;<br>
    *p_y3rdline = 11;<br><br>
    y1stline = *p_y1stline;<br>
    y2ndline = *p_y2ndline;<br>
    y3rdline = *p_y3rdline;*/<br>
    <br>
    gotoxy(1,y1stline);<br>
    printf("Hgt (ft): ");<br>
    *p_xfeet = wherex();<br><br>
    gotoxy(15,y1stline);<br>
    printf("Hgt (in): ");<br>
    *p_xinches = wherex();<br><br>
    gotoxy(35,y1stline);<br>
    printf("Wgt pg (lbs):  ");<br>
    *p_xpoundspg = wherex();<br><br>
    gotoxy(55,y1stline);<br>
    printf("Wgt gvd (lbs):  ");<br>
    *p_xpoundsg = wherex();<br><br>
    gotoxy(1,y2ndline);<br>
    printf("BMI pg:  ");<br>
    *p_xbmipg = wherex();<br><br>
    gotoxy(40, y2ndline);<br>
    printf("BMI gvd:  ");<br>
    *p_xbmig = wherex();<br><br>
    gotoxy(1, y3rdline);<br>
    printf("Elec Spac (cm):  ");<br>
    *p_xelec_spac = wherex();<br><br>
    gotoxy(40, y3rdline);<br>
    printf("Amp Gain:  ");<br>
    *p_xamp_gain = wherex();<br><br>
    gotoxy(20, y3rdline + 2);<br>
    printf("%s\n\n", dummy);<br>
}<br><br>
/*<br>
 * Display Results - a routine to enter the results into the header
created<br>
 * with Enter Header<br>
 */<br><br>
void  display_results(int inches_display, float pounds_pg, float
amp_gain,<br>
      float pounds_g, int feet_display, int
ibmi_pg, int ibmi_g, float elec_spac,<br>
      int xbmig, int xbmipg, int xpoundsg, int
xpoundspg, int xfeet, int xinches,<br>
      int xelec_spac, int xamp_gain, int
y1stline, int y2ndline, int y3rdline)<br><br>
{<br><br>
    gotoxy(xfeet,y1stline);<br>
    printf("%d", feet_display);<br><br>
    gotoxy(xinches,y1stline);<br>
    printf("%d", inches_display);<br><br>
    gotoxy(xpoundspg,y1stline);<br>
    printf("%d", (int)pounds_pg);<br><br>
    gotoxy(xpoundsg,y1stline);<br>
    printf("%d", (int)pounds_g);<br><br>
    gotoxy(xbmipg,y2ndline);<br>
    printf("%d", ibmi_pg);<br><br>
    gotoxy(xbmig,y2ndline);<br>
    printf("%d", ibmi_g);<br><br>
    gotoxy(xelec_spac,y3rdline);<br>
    printf("%d", (int)elec_spac);<br><br>
    gotoxy(xamp_gain,y3rdline);<br>
    printf("%d", (int)amp_gain);<br><br>
}<br><br>
    fspacing = (float)spacing;<br>
    fgain = fspacing/3.0 + 2.0;<br><br>
    gain = (int)fgain;<br>
    if(fgain - gain > 0.5)<br>
        gain = gain +1;<br><br>
    return gain;<br><br>
}<br>
</font>======</body>
</html>
--Boundary_(ID_x2432Oakb0QQ2yMqK5vhqA)--
- Raw text -