I have the following code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
float a, b, c, delt, c0, c1, c2;
char s;
int op = 1;
printf("Welcome.\n\n");
while (op == 1) {
printf("Please type: a, b c.\n\n");
printf("a:");
scanf("%f",&a);
printf("b:");
scanf("%f",&b);
printf("c:");
scanf("%f",&c);
delt = b*b;
printf("%c \n",delt);
printf("Do you want repeat? (y/n)");
scanf("%c",&s);
if (s != "y") {
op = 0;
}
}
return 0;
}
Why does the last scanf()
not wait for input to continue with if
and decide if the process can be terminated?
I'm using the GNU C compiler if it's useful.