בעיה עם מספר if
אני מנסה לעשות תוכנה ששבתוך התנאי if האופציות יתפצלו שוב לשניים (ז"א עוד if) אך המהדר dev c++ כותב לי שיש שגיאה
אני מנסה לעשות תוכנה ששבתוך התנאי if האופציות יתפצלו שוב לשניים (ז"א עוד if) אך המהדר dev c++ כותב לי שיש שגיאה
if (a==0) { if (b!=0) printf("the root for this equation is x=%lf", -c/b); else { if (c==0) printf("There are endless zero point for your equation\n"); else (c!=0) printf("There aren't square roots for the above parameters.\n"); } } else
האם משהו לא נכון במבנה הקוד? (הקוד המלא) #include <stdio.h> #include <math.h> void main() { double a,b,c,f,m; printf("Welcome To The Square Root Program\n"); printf("This program designed to calculate the square root of the square equation\n"); printf("ax^2+bx+c\n"); printf("Please enter the parameter a:\n"); scanf("%lf", &a); printf("Please enter parameter b:\n"); scanf("%lf", &b); printf("Please enter parameter c:\n"); scanf("%lf", &c); if (a==0) { if (b!=0) printf("the root for this equation is x=%lf", -c/b); else { if (c==0) printf("There are endless zero point for your equation\n"); else (c!=0) printf("There aren't square roots for the above parameters.\n"); } } else { if (b*b-4*a*c<0) { printf("There aren't square roots for the above parameters.\n"); printf("Press any key..."); scanf("%lf", &f); } if ((b*b-4*a*c)==0) { printf("There is only one square root for the above parameters."); printf("x=%lf \n",(-b+sqrt(b*b-4*a*c))/(2*a)); } else { printf("The first x (x1) is: %lf\n",(-b+sqrt(b*b-4*a*c))/(2*a)); printf("The second x (x2) is: %lf\n",(-b-sqrt(b*b-4*a*c))/(2*a)); } getchar(); getchar(); } getchar(); getchar(); }