I have this code, the problem is no matter what value I give to "m" the while keeps looping and I don't know why
Here is the code
#include <stdio.h>
#include <math.h>
#include <conio.h>
int main(void){
float ur, N, h1, h2, h3, l1, l2, l3, uo, w, V, i, lc1, lc2, A1, A2, A3, A4, R1, R2, R3, R4, Req, fl, P;
int m;
uo = 4*M_PI*(pow(10, -7));
printf("\n-- Inicio del Problema --");
printf("\n-- Para conocer las variables revise la imagen en la parte trasera de la portada del disco --");
while (m != 1){
printf("\n-- Introduzca Permeabilidad magnetica relativa\t");
scanf("%f", &ur);
printf("\n-- Introduzca voltaje en volts\t");
scanf("%f", &V);
printf("\n-- Introduzca corriente en amperes\t");
scanf("%f", &i);
printf("\n-- Introduzca el número de espiras\t");
scanf("%f", &N);
printf("\n-- Introduzca las alturas en metros (h1, h2 y h3 separados por espacio)\t");
scanf("%f %f %f", &h1, &h2, &h3);
printf("\n-- Introduzca los largos en metros (l1, l2, y l3 separados por espacio)\t");
scanf("%f %f %f", &l1, &l2, &l3);
printf("\n-- Introduzca la anchura en metros (w)\t");
scanf("%f", &w);
printf("\nur = %f \t V = %f V \t I = %f A \t N = %f espiras \nh1 = %f m \t h2 = %f m \t h3 = %f m \nl1 = %f m \t l2 = %f m \t l3 = %f m \t w = %f m", ur, V, i, N, h1, h2, h3, l1, l2, l3, w);
printf("\nHa introducido correctamente los datos (si = 1, no = 2)? \t");
scanf("%d", m);
}
lc1 = l2+(l1/2)+(l3/2);
lc2 = h2+(h1/2)+(h3/2);
A1 = h1*w;
A2 = l3*w;
A3 = h3*w;
A4 = l1*w;
R1 = lc1/(ur*uo*A1);
R2 = lc2/(ur*uo*A2);
R3 = lc1/(ur*uo*A3);
R4 = lc2/(ur*uo*A4);
Req = R1+R2+R3+R4;
fl = (N*i)/Req;
P = V*i;
printf("\n-- Las áreas son: \nA1 = %f m^2 \nA2 = %f m^2 \nA3 = %f m^2 \nA4 = %f m^2", A1, A2, A3, A4);
printf("\n-- Las reluctancias son: \nR1 = %f A*V/wb \nR2 = %f A*V/wb \nR3 = %f A*V/wb \nR4 = %f A*V/wb", R1, R2, R3, R4);
printf("\n-- La reluctancia equivalente es: \nReq = %f A*V/wb", Req);
printf("\n-- El flujo magnetomotriz es: \nF = %f wb", fl);
printf("\n-- La potencia del sistema es: \nP = %f watts", P);
getch();
return 0;
}
I've tried changing to "m == 2", doing a do-while. No matter what I do is either breaks with any answer or doesn't brake with any answer.
I've also tried putting an if/break inside the loop, both while and do-while, but still has the same problems
If you point me to the problem I'd really appreciate it