473,396 Members | 2,017 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,396 software developers and data experts.

What's wrong with my Do While Condition?

16
If for example I have four arrays (with different value), and I have another array which is the result of calculation between these four arrays. Then, I can sort the final array to ascending order and I want to search from the four arrays that can result the sorted final array...

I used do while loop but I guess something wrong with it because it keep resulting 0.

Here's my a part of code which has problem:
Expand|Select|Wrap|Line Numbers
  1.  
  2. for (i=0; i<size2; i++){          
  3.       for (k = 0; k < point3[i]; k++){       
  4.            for (a=0;a<b[i][k];a++){          
  5.                 for (l=0;l<b[i][k];l++){
  6.                      do{
  7.  
  8.                gradient [i][k][a]= fabs((S[i][k][j]-Cy[i][k])/(R[i][k][j]-Cx[i][k]))-teta[i][k][a]; 
  9. //teta[i][k][a] =  fabs((S[i][k][a]-Cy[i][k])/(R[i][k][a]-Cx[i][k])),but in the statement above teta[i][k][a] has already sorted
  10.  
  11.                     X[i][k][a]=R[i][k][l];    
  12.                     Y[i][k][a]=S[i][k][l]; 
  13.                  }
  14.                while (gradient[i][k][a]==0);  
  15.  
  16.                }
  17.               printf ("[%d][%d][%d]=%f\n",i,k,a,X[i][k][a]);   
  18.  
  19.            }
  20.       }
  21.     }
  22.  
  23.  
Could you help me spot the error, please?
May 9 '09 #1
2 1568
weaknessforcats
9,208 Expert Mod 8TB
Have you tried stepping through this with your debugger?
May 9 '09 #2
donbock
2,426 Expert 2GB
I may not be looking closely enough, but it looks to me like the same value will be assigned to gradient[][][] each time through the loop. Nothing changes. I would expect you to either exit from the loop after a single pass or get stuck there in an infinite loop.
May 9 '09 #3

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

Similar topics

226
by: Stephen C. Waterbury | last post by:
This seems like it ought to work, according to the description of reduce(), but it doesn't. Is this a bug, or am I missing something? Python 2.3.2 (#1, Oct 20 2003, 01:04:35) on linux2 Type...
33
by: Diez B. Roggisch | last post by:
Hi, today I rummaged through the language spec to see whats in the for ... else: for me. I was sort of disappointed to learn that the else clauses simply gets executed after the loop-body -...
24
by: Andrew Koenig | last post by:
PEP 315 suggests that a statement such as do: x = foo() while x != 0: bar(x) be equivalent to while True:
12
by: Steven T. Hatton | last post by:
This is something I've been looking at because it is central to a currently broken part of the KDevelop new application wizard. I'm not complaining about it being broken, It's a CVS images. ...
51
by: WindAndWaves | last post by:
Can anyone tell me what is wrong with the goto command. I noticed it is one of those NEVER USE. I can understand that it may lead to confusing code, but I often use it like this: is this...
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
6
by: John Pass | last post by:
What is the difference between a While and Do While/Loop repetition structure. If they is no difference (as it seems) why do both exist?
4
by: nde_plume | last post by:
I need a simple multi-thread/process interlock mechanism, that works on Windows and Linux. However, they have rather different mechanisms. I put together a system that seems to me to work, and be...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
53
by: jaso | last post by:
Can you give any comments on this code? I used one goto, is it bad? #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> #include <assert.h> #define NOT_NULL 1
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...

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.