need help in this simple C++ code!

Jun 15, 2011 at 3:33pm
when i compile this code it gives 8 warnings ,that the variables u01,u02,u13,u12 etc are assigned the values that are never used ...please tell whats the reason and how to correct it! thanx




#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
int u01,u02,u10,u11,u12,u13,u20,u21,u22,u23,u31,u32;
float uit_11,uit_12,uit_21,uit_22;
int k;
u01=50;
u02=50;
u13=75;
u23=75;
u32=55;
u31=55;
u10=100;
u20=100;
u11=0;
u12=0;
u21=0;
u22=0;
for(k=1;k<=200;k++)
{
uit_11=(1/4)*(u21+u01+u12+u10);
uit_12=(1/4)*(u31+u11+u22+u20);
uit_21=(1/4)*(u22+u02+u13+u11);
uit_22=(1/4)*(u32+u12+u23+u21);
cout<<"itration #"<<k<<"_____________"<<endl;
cout<<"U(1,1)="<<uit_11<<endl;
cout<<"U(1,2)="<<uit_12<<endl;
cout<<"U(2,1)="<<uit_21<<endl;
cout<<"U(2,2)="<<uit_22<<endl;
if((fabs(u11-uit_11)<0.00001)&&(fabs(u12-uit_12)<0.00001)&&(fabs(u21-uit_21)<0.00001)&&(fabs(u22-uit_22)<0.00001))
{
u11=uit_11;
u12=uit_12;
u21=uit_21;
u22=uit_22;
break;
}
else
{
u11=uit_11;
u12=uit_12;
u21=uit_21;
u22=uit_22;
}
}
cout<<"The temp.at unknown point U(1,1)="<<u11<<endl;
cout<<"The temp.at unknown point U(1,2)="<<u12<<endl;
cout<<"The temp.at unknown point U(2,1)="<<u21<<endl;
cout<<"The temp.at unknown point U(2,2)="<<u22<<endl;
getch();
}


Jun 15, 2011 at 3:54pm
Please use code tags around code so that we have an easier time reading it.

I tried to compile and run this code and I'm not having trouble...except for with getch()/conio.h which my compiler doesn't seem to like. I use GCC 4.4.5 on Linux. What compiler and OS are you using?

I don't see any reason why you would get those warnings. Perhaps you can tell us what you are trying to do and we can offer more advice?
Jun 15, 2011 at 6:10pm
i am usng windows XP,and Turbo C ,i just simply want to evaluate that formula until the results start repeating itself and then want to show it on screen,initially i have given 0 to those unknown points then after each iteration the previous result is used as these unknown points and so on untill the results repeat ,then assigned these iterative variables to the original unknown variables,but if the results do not repeat itself then continue doing the same process....
Topic archived. No new replies allowed.