i am new to c and turboc.
and i am learning it .
i hope you can help me .
thanks . 7 1411
#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. They just started trading
this one like 2 days...
|
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 image will not be found for the browser is going to...
|
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 va_arg_example(const char *format, ...)
{
va_list...
|
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 why!
I have a VB6 program that works...
|
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 business
as you know when we travel we meet a lot...
|
by: foxfox05 |
last post by:
HI ........ IF YOU WANT GIRL FRIENDS ...........
SEE THIS ....... CHAT , VIDEO CHAT , E MAIL ,
http://indianfriendfinder.com/go/g966057
http://youthsworlds.blogspot.com
HI ........ IF ...
|
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 we travel we meet a lot of different cultures and...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |