Need help for simple program, don't have a clue about C.

Please, can you help me? I have 3 errors
- Undefined symbol i
- Undefined symbol y and
- Compound statement missing

See the program bellow:

``````#include<stdio.h>
#include<conio.h>
#include <math.h>
void main( )
{
float a, b, c,x3;
float a0,a1,a2;
clrscr( );
printf("Raiz: x = a + bi ");
printf("Digite o valor de a: ");
scanf("%f",&a);
printf("Digite o valor de b: ");
scanf("%f",&b);
printf("Digite o valor de x3: ");
scanf("%f",&x3);
printf("As raizes sao: ");
printf("x1 = %.2f + %.2f i \n",a,b);
printf("x2 = %.2f - %.2f i \n ",a,b);
printf("x3 = %.2f \n",x3);
a0=-(a*a+b*b)*x3;
a1=(a*a+b*b)+x3*2*a;
a2=-(2*a+x3);
printf("a0= %f a1=%f a2=%f \n\n",a0,a1,a2);
printf("Polinomio y = x3 + %.2fxý + %.2fx + %.2f \n",a2,a1,a0);
//Oráculo para verificar a situação de cada ponto se IN, OUT, ON
for(i=-20;i<=20;i++)
{
y= (i*i*i) + (a2*i*i) + (a1*i) + a0;
if(y<-20)
printf(" x = %i \t y = %.2f OUT\n",i,y);
if(y==-20)
printf(" x = %i \t y = %.2f ON\n",i,y);
if(y>-20 && y<20)
printf(" x = %i \t y = %.2f IN\n",i,y);
if(y==20)
printf(" x = %i \t y = %.2f ON\n",i,y);
if(y>20)
printf(" x = %i \t y = %.2f OUT\n",i,y);
getch( );
}``````

Edited by Nick Evan: added code tags

gah..
Fail.
2
Contributors
2
Replies
4
Views
8 Years
Discussion Span
Last Post by jephthah

The next time you wish to drop another load, let me suggest that you start a new thread all on your own. That way you won't soil someone else's thread, you won't confuse other students else with your broken, non-portable junk, and we can tell you why your code is crap.

compile errors include:
-- void(main), main requires int return
-- conio, deprecated library unavailable.
-- clrscr, unknown function
-- getch, unknown function

crappy coding style, unreadable, sloppy uses include:
-- no whitespace
-- no indentations
-- scanf
-- <math.h> library.... for what purpose?

given all of the above, i have doubts this will even work correctly. I'm certainly not going to go and fix these problems just to get it to compile properly to find out it's got more problems.

In the future the very least you can do, in a general C language forum, is two simple things:

(1) make sure your completed code COMPILES on any standard C compiler.
(2) make sure your completed code is READABLE without someone having to go through contortions to edit it.

[FAIL]

.

Edited by jephthah: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.