473,395 Members | 1,527 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

hi!every one !

jim

i am new to c and turboc.
and i am learning it .
i hope you can help me .
thanks .

Mar 14 '06 #1
7 1411
jim
#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

Mar 14 '06 #2
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
==============
Mar 14 '06 #3
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)
Mar 14 '06 #4
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

Mar 14 '06 #5

"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

Mar 14 '06 #6

"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
Mar 14 '06 #7
jim
thank u very much
and i have knewn what is wrong with it

Mar 15 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
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...
7
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...
8
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...
5
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...
9
by: FERHAT AÇICI | last post by:
hi all! who know arrays on visual basic please tell me.... thanks..
0
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 ...
0
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...
0
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 ...
0
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...
0
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...
0
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...
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
marktang
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,...
0
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...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.