Thread: Why is it blank?

  1. #1
    Unregistered
    Guest

    Question Why is it blank?

    Can someone tell me why this code produces a blank DOS window? It doesn't even say "Press any key to continue".

    #include <stdio.h>
    #include <math.h>

    int main(void)
    {
    double x[11], fx[11];

    double xvalue=0.9;
    double pxtemp[11];
    double px=0;
    int i,j,m,n,k,p,q;



    x[0]=-1.0;

    for(i=1;i<=10;i++)
    x[i]=x[i-1]+0.2;

    fx[0]=0.104549;
    fx[1]=0.111558;
    fx[2]=0.143333;
    fx[3]=0.234702;
    fx[4]=0.520405;
    fx[5]=1.000000;
    fx[6]=0.520405;
    fx[7]=0.234702;
    fx[8]=0.143333;
    fx[9]=0.111558;
    fx[10]=0.104549;

    for(j=0;j<=10;j++)
    pxtemp[j]=1;

    for(n=0;n<=10;n++)
    {
    for(k=0;k<=10;k++)
    {
    if(k=n)

    pxtemp[n]=pxtemp[n];
    else
    pxtemp[n]=pxtemp[n]*(xvalue-x[k]);
    }
    }

    for(p=0;p<=10;p++)
    {
    for(q=0;q<=10;q++)
    {
    if(p=q)
    pxtemp[p]=pxtemp[p];
    else
    pxtemp[p]=pxtemp[p]/(x[p]-x[q]);
    }
    }


    for(m=0;m<=10;m++)
    {
    px=px+pxtemp[m];
    }

    printf("%lf \n",px);
    return 0;
    }

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >if(k=n)
    should be
    if ( k == n )

    >if(p=q)
    once again
    if ( p == q )

    Make those two changes and your program will output correctly.

    -Prelude
    My best code is written with the delete key.

  3. #3
    Unregistered
    Guest

    Smile

    Thanks! It still doesn't output the RIGHT answer, but at least it outputs something!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem opening blank files with ifstream.
    By Sclorch in forum C++ Programming
    Replies: 4
    Last Post: 02-07-2009, 11:43 AM
  2. Problem with deleting completely blank lines
    By dnguyen1022 in forum C Programming
    Replies: 3
    Last Post: 12-07-2008, 11:51 AM
  3. Discarding blank lines?
    By Blurr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 12:30 PM
  4. Replies: 3
    Last Post: 04-27-2005, 11:50 AM
  5. Check for a blank cd-r
    By waldis in forum C++ Programming
    Replies: 3
    Last Post: 02-23-2003, 06:16 PM