473,498 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

show maximum value only

25 New Member
this is my nested loop to only show maximum z value only, but it always shows the last value of z. Could someone help me please?

double x;
double y;
double z;
int maxz = INT_MIN;

for (x = 5.0;x >= 1.0;x--)
{
for (y = 5.0;y >= 1.0;y--)
{
z = x * y;
if (z > maxz)
{
maxz = z;
}
}
}
printf(max z is %.2lf\n",z);

another question, Can i use INT_MIN value to compare double type variable instead?
Sep 12 '06 #1
3 5651
Banfa
9,065 Recognized Expert Moderator Expert
You are print z instead of maxz in the printf statement.

And I've have thought DBL_MIN would be a better constant to use, available in float.h


Using doubles and floats as loop control variables is flaky at best due to the inaccurate nature of floating point types.
Sep 12 '06 #2
evantri
25 New Member
I'm sorry, but could you give me the complete code please. I've tried to do that but it still does not work. Sorry for bothering you, I'm new at C so I'm still pretty crappy in this language. Thanks
Sep 12 '06 #3
Banfa
9,065 Recognized Expert Moderator Expert
I'm sorry, but could you give me the complete code please. I've tried to do that but it still does not work. Sorry for bothering you, I'm new at C so I'm still pretty crappy in this language. Thanks
I would have thought you could change z to zmax in the printf statement yourself. Position the cursor after the z and type m a x

If you are refering to

"Can i use INT_MIN value to compare double type variable instead?"

This does not really make sense but since you are using doubles I though the using DBL_MIN (the minimum value a double can hold) rather than INT_MIN (the minimum value an int can hold and about 10e300 time larger then DBL_MIN) would be better.

I helpfully told you that DBL_MIN is defined in float.h all you have to do is include it at the top of your file. Something you must have already done with limits.h to be using INT_MIN.
Sep 12 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
2597
by: Till Crueger | last post by:
Hi, I have to implement some simple sorting algorithm. I am NOT asking for you to do my homework, but my question is rather on how to store the integers. I recall reading once in here that there...
2
2308
by: Hennie de Nooijer | last post by:
Because of an error in google or underlying site i can reply on my own issue. Therefore i copied the former entered message in this message....
2
28520
by: Kums | last post by:
What is the maximum permissible size of a database? Is there any limitation. What is the maximum # of tablespace's allowed in a database? Thanks for your response.
9
1976
by: Martin Ho | last post by:
My application should check for new updates when user chooses this option in the menu. It should go online and check the flag and compare with current flag in the programs directory. If version is...
7
2122
by: Loane Sharp | last post by:
Hi there I'm currently using WebClient.DownloadFile to download a file from the server to my local disk. Is there a way to show the progress of the file download? Best regards Loane
29
5052
by: garyusenet | last post by:
I'm trying to investigate the maximum size of different variable types. I'm using INT as my starting variable for exploration. I know that the maximum number that the int variable can take is:...
130
6373
by: Daniel Manes | last post by:
I'm baffled. I have a column in a SQL Server Express database called "Longitude," which is a float. When I view the table in a DataGridView, some of the numbers, which only have two decimal places...
0
1540
by: runway27 | last post by:
hi my question is about "SHOW TABLE STATUS LIKE 'tablename'"; following is the code i am presently using ================================================================== $conn =...
1
3351
by: maurizio | last post by:
thank you for your answer actually i've to do some statistics (maximum,minimum,mean,standard deviation,....) of a file of data in which each column is a particular type of data. (the file is a tab...
0
6993
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
7162
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7197
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7375
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...
1
4899
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4584
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1411
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.