Google Search

Monday, April 4, 2011

Simulation of chemical reaction


#include<iostream.h>
#include<conio.h>
#include<dos.h>

void main()
{
   float a=50,b=25,c=0,k1=.025,k2=.01,x,y,z,t=0.1;
   int i;
   clrscr();
   cout<<"Press any key to exit.......";
   cout<<"\n\nInitial conc. are : "<<"A="<<a<<"    B="<<b<<"    C="<<c;
   for(i=1;i<150;i++)
   {

      if(kbhit())
      {
 break;
      }

x=(k2*c-k1*a*b)*.1;
y=(k2*c-k1*a*b)*.1;
z=(2*k1*a*b-2*k2*c)*.1;
a=a+x;
b=b+y;
c=c+z;
cout<<"\nConc. after time t="<<t<<"is  :  A="<<a<<"    B="<<b<<"    C="<<c;
delay(1000);
t=t+.1;
   }
   getch();

}

0 comments:

Post a Comment