-3
I’m looking to make an ATM with only 10 notes, with a limit of 1000 ballots. However, you have to show me how many ballots are in the box and how much is left to remove, and that it is possible to withdraw as many times as you want until the notes run out. However, when I put the amount I want to withdraw the program does not show the amount of ballots withdrawn and when I answer anything the program closes, and it could only be closed when I answered "N".
#include<stdio.h>
main()
{
char R[1];
int S, SQ, Nc, Vt;
Nc=1000;
Vt=10000;
while(R!="N" || Nc>0)
{
printf("limite:%d",Vt);
printf("\nDigite quanto deseja sacar:");
scanf("%d",&S);
SQ=S/10;
if ((S<0) || (S>Vt) || (S%10!=0))
printf("Valor invalido");
printf("\nDeseja realizar outro saque? [S/N]");
scanf("%s",&R);
break;
if ((S%10==0) && (S<Vt))
printf("%d nota(s) de 10.", SQ);
printf("Deseja realizar outro saque? [S/N]");
scanf("%s",&R);
Vt=Vt-S;
Nc=Nc-SQ;
break;
if (Nc == 0)
printf("Sem notas");
break;
}
}
We who ask: where is the error? What is happening?
– Ronaldo Araújo Alves
Seems related to me: https://answall.com/q/386706/3774
– Icaro Martins
The program fails, but after we respond as we wish to withdraw the program.
– Marckson
Maybe that’s the problem
if (Nc = 0)
one more comparison=
instead of==
– Icaro Martins
I just made the change, but the program keeps closing after I put the loot value.
– Marckson
Ok, so now it’s only worth you [Edit] the question and put the new code fixed and maybe add more information like: What is going on, Shows an error, Steps for error to occur, ... This will help the community identify and explain what is happening =D -- don’t forget to take a look at our [Tour]
– Icaro Martins
correct the indentation of your code, to facilitate the understanding of other people
– zentrunix