I am a newbie in coding. I am writing an online shopping code in C, I don’t know why but my code goes into an infinite loop and the scanf function in the block does not work. Even if I add if (b\<=a){break;}. My friend tried to run it on Linux and got a different result. It just writes "insufficient margin please add" several times depending on the input. Here’s my code;
int b = 100;
int add;
scanf("%d",&a);
while(a\<b)
{
printf("unsiffcent margin please add");
scanf("add%d",&add);
a = a + add;
}
I tried adding if(b\<=a){break;} but doesn’t work. I want a code that ask me too add to a number until number is greater than a value.
>Solution :
scanf("%d",&add); will solve your problem