Skip to content
Snippets Groups Projects
Commit a8069991 authored by Jakub Węgrowski's avatar Jakub Węgrowski
Browse files

Upload New File

parent 72e82b0c
Branches
No related merge requests found
lab_3.c 0 → 100644
int main(){
printf("even/odd\n");
int x;
printf("give a whole number: ");
scanf("%i", &x);
if (x == 0){printf("number is 0\n");}
else if (x%2 == 1){printf("number is odd\n");}
else {printf("number is even\n");};
printf("\nequation\n");
float a, b, c;
printf("give values of a,b,c for: \na * x^2 + b * x + c\n");
printf("a = ");scanf("%f", &a);
printf("b = ");scanf("%f", &b);
printf("c = ");scanf("%f", &c);
printf("equation formula is:\n%f * x^2 + %f * x + %f", a, b, c);
if (a==0 && b ==0 && c==0){printf("\nequation is indeterminate");}
else if (a==0 && b==0){printf("\nequation is contradictory");}
else if (a == 0){printf("\nequation is linear\nsolution of the equation is: %f",-c/b);}
else {printf("\nequation is quadratic");
float d = b*b-4*a*c;printf("%f",d);
if (d == 0){printf("\nsolution of the equation is: %f",-b/(2*a));}
else if (d > 0){printf("\nsolutions of the equation are: %f and %f",(-b-sqrt(d))/(2*a),(-b+sqrt(d))/(2*a));}
else {(printf("\n solutions of the equation are: %f + %f i and %f + %f i",-b/(2*a),-sqrt(-d)/(2*a),-b/(2*a),sqrt(-d)/(2*a)));};
};
printf("\n");
};
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment