Qube
Member level 5
here's the program...
the idea
there are 2 groups named as hash and mad
hash has 85 people
mad has 15 people
hash group grows @ 10% per decade
mad group grows @ 30% per decade..
Now this program has to calculate after how many decade hash group n mad group will have same strength....
here's the code
#include<iostream.h>
#include<conio.h>
float growth_cal(float,int);
main()
{
clrscr();
cout<<" \t\t\t Growth by decade\n\n\n";
cout<<" Enter the values\n";
float hbase_pop=0.0,hpercent,hgrowth=0.0;
float mbase_pop=0.0,mpercent,mgrowth=0.0;
cout<<"Enter the Base value of M\n";
cout<<">>";
cin>>mbase_pop;
cout<<"Enter the growth percent of M\n";
cout<<">>";
cin>>mpercent;
cout<<"Enter the Base value of H\n";
cout<<">>";
cin>>hbase_pop;
cout<<"Enter the growth percent of H\n";
cout<<">>";
cin>>hpercent;
int targetdec=0;
loop:
mgrowth=growth_cal(mbase_pop,mpercent);
hgrowth=growth_cal(hbase_pop,hpercent);
mbase_pop=mbase_pop+mgrowth;
hbase_pop=hbase_pop+hgrowth;
targetdec++;
if(mbase_pop==hbase_pop)
{
cout<<"The number of decade when both are equal ="<<targetdec;
}
else
{
goto loop;
}
getch();
}
//Functions
float growth_cal(float b,int d)
{
float growth,growth1;
growth=b*d;
growth1=growth/100;
return growth1;
}
if i excecute ctrl F9..the output screen exits after i press alt+F5 ,
floating point errorverflow
abnormal program termination
plz debug this code...
the idea
there are 2 groups named as hash and mad
hash has 85 people
mad has 15 people
hash group grows @ 10% per decade
mad group grows @ 30% per decade..
Now this program has to calculate after how many decade hash group n mad group will have same strength....
here's the code
#include<iostream.h>
#include<conio.h>
float growth_cal(float,int);
main()
{
clrscr();
cout<<" \t\t\t Growth by decade\n\n\n";
cout<<" Enter the values\n";
float hbase_pop=0.0,hpercent,hgrowth=0.0;
float mbase_pop=0.0,mpercent,mgrowth=0.0;
cout<<"Enter the Base value of M\n";
cout<<">>";
cin>>mbase_pop;
cout<<"Enter the growth percent of M\n";
cout<<">>";
cin>>mpercent;
cout<<"Enter the Base value of H\n";
cout<<">>";
cin>>hbase_pop;
cout<<"Enter the growth percent of H\n";
cout<<">>";
cin>>hpercent;
int targetdec=0;
loop:
mgrowth=growth_cal(mbase_pop,mpercent);
hgrowth=growth_cal(hbase_pop,hpercent);
mbase_pop=mbase_pop+mgrowth;
hbase_pop=hbase_pop+hgrowth;
targetdec++;
if(mbase_pop==hbase_pop)
{
cout<<"The number of decade when both are equal ="<<targetdec;
}
else
{
goto loop;
}
getch();
}
//Functions
float growth_cal(float b,int d)
{
float growth,growth1;
growth=b*d;
growth1=growth/100;
return growth1;
}
if i excecute ctrl F9..the output screen exits after i press alt+F5 ,
floating point errorverflow
abnormal program termination
plz debug this code...