prob with my cimple prog

This is a discussion on prob with my cimple prog within the C Programming forums, part of the General Programming Boards category; The use of this program is that there is an equation,the program asks for the inputs in this equations and ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    46

    prob with my cimple prog

    The use of this program is that there is an equation,the program asks for the inputs in this equations and the tries to get the value of (f) which is present in both sides of the equation that would make both sides equals.The prob is that after the inputs are given nothing happens.

    Code:
    #include<stdio.h>
    #include<math.h>
    int main(void){
    char wish;
    int ks,rn,d;
    float f;
    printf("Enter the value of Ks : ");
    scanf("%d", &ks);
    printf("\nEnter the value of D : ");
    scanf("%d", &d);
    printf("\nEnter the value of RN : ");
    scanf("%d", &rn);
    while((1/sqrt(f))!=-2*log((ks/(3.71*d))+(2.51/(rn*sqrt(f))))){
                                                                         f+=0.01;
                                                                         }
                                                                         printf("Frequency f=%f2.1",f);}

  2. #2
    Mad OnionKnight's Avatar
    Join Date
    Jan 2005
    Location
    Umeň, Sweden
    Posts
    555
    That means the program never enters the loop and that means that the loop condition evaluated to false. Evaluate the condition yourself by hand with the same input data to see where it goes wrong.

  3. #3
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    f is never given a starting value. Comparing for floating point (in)equality is not so simple: http://c-faq.com/fp/fpequal.html.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  4. #4
    Registered User
    Join Date
    Sep 2005
    Posts
    46
    thanks guys

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Deal or No Deal listbox prob
    By kryptkat in forum Windows Programming
    Replies: 5
    Last Post: 03-30-2009, 06:53 PM
  2. Bor to DevC++ prog convert prob
    By kryptkat in forum Windows Programming
    Replies: 16
    Last Post: 09-18-2007, 05:11 AM
  3. getch() prob
    By kryptkat in forum C Programming
    Replies: 29
    Last Post: 07-05-2007, 09:27 AM
  4. Prog Prob
    By polonyman in forum C++ Programming
    Replies: 10
    Last Post: 09-11-2004, 08:54 AM
  5. if-else prob..very basic so sorry to trouble u guys
    By bugeye in forum C Programming
    Replies: 2
    Last Post: 01-26-2002, 07:55 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21