i am new to c and turboc.
and i am learning it .
i hope you can help me .
thanks . 7 1368
#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
jim wrote: #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
Which inputs do you expect to produce which outputs? What is the code
trying to solve for you?
--
==============
Not a pedant
==============
jim said: #include<stdio.h> #include<math.h> void main()
main returns int, not void. So make that:
int main(void)
{ float x,y,z; scanf("%f,%f\n",&x,&y) ;
scanf returns a value, which you need to check, in case something went
wrong. z=(fabs(x)-2)*(fabs(x)-2)+(fabs(y)-2)*(fabs(y)-2)-1;
What is this supposed to do? Let's assume that x has the value 3.0, and y
has the value 4.0.
fabs(3.0) is 3.0.
fabs(3.0) - 2 is 1.0.
(fabs(3.0) - 2) * (fabs(3.0) - 2) is 1.0.
fabs(4.0) is 4.0.
fabs(4.0) - 2 is 2.0.
(fabs(4.0) - 2) * (fabs(4.0) - 2) is 4.0.
(fabs(3.0) - 2) * (fabs(3.0) - 2) + (fabs(4.0) - 2) * (fabs(4.0) - 2) is
5.0.
(fabs(3.0) - 2) * (fabs(3.0) - 2) + (fabs(4.0) - 2) * (fabs(4.0) - 2) - 1 is
4.0.
So z takes the value 4.0.
Is that what you were expecting? 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");
main returns int, so add:
return 0; } i wote it,but it can not run rightly!
What do you mean by "run rightly"? What is it supposed to do?
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
On Tuesday 14 March 2006 11:06, jim opined (in
<11**********************@i40g2000cwc.googlegroups .com>): i am new to c and turboc. and i am learning it . i hope you can help me .
And your question was? Once you have one, you're more than welcome to
post it here. Before you do, please read and heed:
<http://cfaj.freeshell.org/google/>. This one
<http://clc-wiki.net/wiki/Introduction_to_comp.lang.c> is also useful
if you want to avoid friction with the regulars.
--
BR, Vladimir
Power is danger.
-- The Centurion, "Balance of Terror", stardate 1709.2
"jim" <ab********@gmail.com> wrote in message
news:11**********************@j52g2000cwj.googlegr oups.com... #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
--
RSH
"Robin Haigh" <ec*****@leeds.ac.uk> wrote in message
news:dv**********@newsg1.svr.pol.co.uk... "jim" <ab********@gmail.com> wrote in message news:11**********************@j52g2000cwj.googlegr oups.com... #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
Nice call. With a TTF, I can't even see that comma...
RP
thank u very much
and i have knewn what is wrong with it This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: sheldon279 |
last post by:
Hi guys. First time poster long time reader.
Just wanted to say "Hi" ;)
On a side note my Hubby is REAL excited about
this new IPO stock GRDX....
|
by: George Hester |
last post by:
Some images I want to link to using the IMG element have a name such as hi%20there.jpg. If I try to do this:
<img src="hi%20there.jpg">
the...
|
by: Eric Lilja |
last post by:
As the title, says: Why doesn't the following program print Hi
Charles<newline> when run?
#include <stdarg.h>
#include <stdio.h>
static void...
|
by: |
last post by:
Hi everyone
Just a quick question! Everytime i run the SCardConnect Command
SCARD_E_INVALID_PARAMETER is returned and i have absolutely no idea...
|
by: FERHAT AÇICI |
last post by:
hi all! who know arrays on visual basic please tell me....
thanks..
|
by: [Cool staff!||Hi! I think this need for || Help me |
last post by:
http://con-cern.org/files/2007/5/xenical-21024312.html cheap xenical http://con-cern.org/files/2007/5/auto-21024411.html auto loan refinance ...
|
by: Tagrislam |
last post by:
Hi Hi Hi
my name is tagreed , I am from Syria
I've seen many places of the world on TV screen and few that I've
visited either for fun or/ and...
|
by: foxfox05 |
last post by:
HI ........ IF YOU WANT GIRL FRIENDS ...........
SEE THIS ....... CHAT , VIDEO CHAT , E MAIL ,
http://indianfriendfinder.com/go/g966057
...
|
by: the great win |
last post by:
Hi
My name is fatima
I’ve seen many places of the world on TV screen and few that I’ve
visited either for fun or/and business
As you know when...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...
| |