What is wrong with my code?

My codes won’t run after for ( Z!=0), Why is that??

Message log says, some initializations didn’t used while compiling code.



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

int main (){

int A,B,C,D,Z,change,sum,answer,X1,X2,X3,X4,X5,X6,X7,icount1,icount2,icount5,icount10,fcount1,fcount2,fcount5,fcount10,ocount1=0,ocount2=0,ocount5=0,ocount10=0,scount1,scount2,scount5,scount10;
//icount = how many coin input, fcount= after coins inserted first coin update, ocount = how many coins output, scount= after coins output second coin update//
int t1count10=100,tcount10,t1count5=100,tcount5,t1count2=100,tcount2,t1count1=100,tcount1;

cout << "How many 10 coins ?" << endl;
cin>> A;
icount10=A;


cout<< "How many 5 coins ?" << endl;
cin >> B;
icount5=B;

cout << "How many 2 coins ?" << endl;
cin >> C;
icount2=C;
cout << "How many 1 coins ?" << endl;
cin >> D;
icount1=D;

sum=10*A+5*B+2*C+D;

for (int R; R!=1;)
{
cout << " Press 1 to get Delta Toffies - One Toffy is Rs:1" << endl;
cout << " Press 2 to get Choclate Toffies - One Toffy is Rs:2" << endl;
cout << " Press 3 to get Milk Choclates - One Choclate is Rs:10" << endl;
cout << " Press 4 to get Lemon Juice Packet - One Packet is Rs:15" << endl;
cout << " Press 5 to get Water Bottle - One Bottle is Rs:20" << endl;
cout << " Press 6 to get Milo - One Milo is Rs:35" << endl;
cout << " Press 7 to get Tip Tip - One Tip Tip is Rs:45" << endl;

cin >> answer;

switch (answer){
case 1:
cout << " How many Delta toffies do you need? " << endl;
cin>> X1;
if (X1<=sum){
cout << " Here are your toffies! " << endl;
if (1*X1 <= sum){
change = sum-1*X1;
change = Z;
}
}
else
cout << " Invalid amount! Try again " << endl;
break;

case 2:
cout << " How many Choclate toffies do you need? "<< endl;
cin >> X2;
if (2*X2<=sum){
cout << " Here are your toffies! " << endl;
if (2*X2 <= sum){
change = sum-2*X2;
change = Z;
}
}
else
cout << " Invalid amount! Try again " << endl;
break;

case 3:
cout << " How many Milk Choclates do you need? " << endl;
cin>> X3;
if (X3<=sum){
cout << " Here are your Milk Choclates! " << endl;
if (10*X3 <= sum){
change = sum-10*X3;
change = Z;
}
}
else
cout << " Invalid amount! Try again " << endl;
break;

case 4:
cout << " How many Lemon Juice Packets do you need? " << endl;
cin>> X4;
if (X4<=sum){
cout << " Here are your Lemon Juice Packets! " << endl;
if (15*X4 <= sum){
change = sum-15*X4;
change = Z;
}
}
else
cout << " Invalid amount! Try again " << endl;
break;
case 5:
cout << " How many Water Bottles do you need? " << endl;
cin>> X5;
if (X5<=sum){
cout << " Here are your Water Bottles! " << endl;
if (20*X5 <= sum){
change = sum-20*X5;
change = Z;
}
}
else
cout << " Invalid amount! Try again " << endl;
break;

case 6:
cout << " How many Milos do you need? " << endl;
cin>> X6;
if (X6<=sum){
cout << " Here are your Milos! " << endl;
if (35*X6 <= sum){
change = sum-35*X6;
change = Z;
}
}
else
cout << " Invalid amount! Try again " << endl;
break;

case 7:
cout << " How many Tip tips do you need? " << endl;
cin>> X7;
if (X7<=sum){
cout << " Here are your Tip tips! " << endl;
if (45*X7 <= sum){
change = sum-45*X7;
change = Z;
}
}
else
cout << " Invalid amount! Try again " << endl;
break;
}


if ( Z!=0){
cout << "Your Change is " << Z <<" & Here are your Change " << endl;
int Z1,Z2,Z3,Z4;
ocount10= Z/10;
Z1= Z%10;
scount10 = icount10-ocount10;
tcount10 = t1count10 + scount10;
if (tcount10>=100){
tcount10 = 100;
}
else if (tcount10>=0){
t1count10=tcount10;
}
if (tcount10 >= 2 ){
cout << "Number of 10 coins " << ocount10 << endl;
}
else
Z=Z1;

ocount5=Z1/5;
Z2=Z1%5;
scount5 = icount5-ocount5;
tcount5 = t1count5 + scount5;
if (tcount5>=100){
tcount5 = 100;
}
else if (tcount5>=0){
t1count5=tcount5;
}
if (tcount5 >= 2 ){
cout << " Number of 5 coins " << ocount5 << endl;
}
else
Z=Z2;

ocount2=Z2/2;
Z3=Z2%2;
scount2 = icount2-ocount2;
tcount2 = t1count2 + scount2;
if (tcount2>=100){
tcount2 = 100;
}
else if (tcount2>=0){
t1count2=tcount2;
}
if (tcount2 >= 2 ){
cout << " Number of 2 coins " << ocount2 << endl;
}
else
Z=Z3;

ocount1=Z3/1;
Z4=Z3%1;
scount1 = icount1-ocount1;
tcount1 = t1count1 + scount1;
if (tcount1>=100){
tcount1 = 100;
}
else if (tcount1>=0){
t1count1=tcount1;
}
if (tcount1 >= 2 ){

cout << " Number of 1 coins " << ocount1 << endl;
}
else
R=1;
cout << "Out of Change! Please enter correct Change only" << endl;
}
else
cout << "Thank you" << endl;
}
getch ();

return 0;

}


oum, that means this
int Z1,Z2,Z3,Z4;
not used. i i don’t know what is this error, but i know create variable in a if that may not run and use that in another line(out of if block) is wrong
Z2=Z1%5;
if Z!=0 return False you have no Z2 for use.

is better that variable that you want use, create in first line of main(), such as:
int A,B,C,D,Z,change,sum,...

i stuck with making comment
help me