J
jim
i am new to c and turboc.
and i am learning it .
i hope you can help me .
thanks .
and i am learning it .
i hope you can help me .
thanks .
jim said:#include<stdio.h>
#include<math.h>
void main()
{
float x,y,z;
scanf("%f,%f\n",&x,&y) ;
z=(fabs(x)-2)*(fabs(x)-2)+(fabs(y)-2)*(fabs(y)-2)-1;
if(z<=1e-6)
{
printf("the height of the dot is 10 m .\n");
}
else
printf("the height of the dot is 0 m .\n");
}
i wote it,but it can not run rightly!
would u tell me what is wrong with it ?
thanks
#include<stdio.h>
#include<math.h>
void main()
{
float x,y,z;
scanf("%f,%f\n",&x,&y) ;
z=(fabs(x)-2)*(fabs(x)-2)+(fabs(y)-2)*(fabs(y)-2)-1;
if(z<=1e-6)
{
printf("the height of the dot is 10 m .\n");
}
else
printf("the height of the dot is 0 m .\n");
}
i wote it,but it can not run rightly!
i am new to c and turboc.
and i am learning it .
i hope you can help me .
jim said:#include<stdio.h>
#include<math.h>
void main()
{
float x,y,z;
scanf("%f,%f\n",&x,&y) ;
[snip]
Robin Haigh said:jim said:#include<stdio.h>
#include<math.h>
void main()
{
float x,y,z;
scanf("%f,%f\n",&x,&y) ;
[snip]
Your problem might just be the scanf format. scanf is very picky, not easy
to master, and possibly not worth it. For now though, changing the format
to just "%f%f" might do what you want
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.
Hi! | 0 | |
Hi! | 0 | |
Hi | 1 | |
Hi! | 0 | |
Hi Everyone! | 2 | |
Hi coders | 5 | |
Hi From Canada | 3 | |
Hi all | 0 |