Game Development Community

c help

by John Moore · in Technical Issues · 01/30/2002 (6:57 pm) · 4 replies

im taking a c class and i have to turn this in tomorrow but it wont run right


#include
main ()
{
float area;
int valx, valy;
char shape;
printf("This program will calculate the area of a shape\n");
printf("Press C for circle, S for square, R for rectangle and T for triangle:");
scanf("%c" ,&shape);
fflush(stdin);
shape=toupper(shape);
if(shape=='C')
{
printf("Enter the Radius of the circle:");
scanf("%d",&valx);
area = valx*3.14;
printf("The area of a circle with a radius of is:%9.2f\n",&area);
}
else
if(shape=='S')
{
printf("Enter the length of a side of the square:");
scanf("%d",&valx);
area = valx*valx;
printf("The area of a square when one side has a length of %f is %9.2f\n", &valx, &area);
}
else
if(shape=='R')
{
printf("Enter the length and height of the rectangle:");
scanf("%d%d",&valx,valy);
area = valx*valy;
printf("The area of the rectangle with a length of %f and width of %f is %9.f\n",&valx,&valy,&area);
}
else
if(shape=='T')
{
printf("Enter the base and heigth of the triangle:");
scanf("%d%d"); valx,valy;
area=valx*valy/2;
printf("The area of a triangle with %f as the base and %f as the height is %9.f\n",&valx,&valy,&area);
}
else
printf("Wrong letter!\n");
return(0);
}

#1
01/30/2002 (7:10 pm)
Oh and do you have an essay for me to write for English? What about a obstacle course for me to run for you in PE?

ohh! yay!

I'll look at it, but I've never really cared much for the online "uh do my homework" people. I never did that when I had problems with c.
#2
01/30/2002 (7:13 pm)
I don't either, but there are better ways to handle the situation.
#3
01/30/2002 (7:18 pm)
if its compiling/linking error, bring out your C reference book check the error.
if its run time error, bring out your debugger.


anyway, make it work before tomorrow even if it means no sleeping tonight.
#4
01/30/2002 (7:35 pm)
im pretty sure that i have it now thanks anyways.