Error in program


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Error in program

  1. #1
    Samuel Guest

    Error in program


    Hi
    I am a med student trying to help his girlfriend with a C++ program. I read
    a little bit of nomenclature trying to find the error. This program is supposed
    to calculate the standard deviation. Please help me! There is a copy of the
    program...is a very very short one.

    Thank you!
    Sam
    pr2004@hotmail.com

    #include <stdio.h>
    #include <iostream.h>
    #include <math.h>
    #define num 5

    main ()
    {
    int vector[num], vector[num];


    int incializar()
    {
    for (i=0;i<num;i++)
    vector[i]=0;
    }

    int GetData (int i, int vector[num])
    {
    for (i=0;i<num;i++)
    cout<<"Entre los numeros"<<end1;
    cin>>vector[i];
    return (vector);

    float CalcMedia (float media, int suma )
    {
    for (i=0;i<num;i++)
    suma = vector[i] + vector [i +1];
    media = float (suma) / num;
    return (media);
    }

    float DesviacionEstandar (float vector[num], float vector2[num],float sum,float
    de)
    {
    for (i=0;i<num;i++)
    vector2[i]=vector [i] - media;
    vector2[i]=pow(vector2[i],2);
    sum=vector2[i] + vector2[i+1] /num;
    de=sqrt(sum);
    return(de)
    }

    }


  2. #2
    marc Guest

    Re: Error in program


    "Samuel" <pr2004@hotmail.com> wrote:
    >
    >Hi
    >I am a med student trying to help his girlfriend with a C++ program. I read
    >a little bit of nomenclature trying to find the error. This program is supposed
    >to calculate the standard deviation. Please help me! There is a copy of

    the
    >program...is a very very short one.
    >
    >Thank you!
    >Sam
    >pr2004@hotmail.com
    >
    >#include <stdio.h>
    >#include <iostream.h>
    >#include <math.h>
    >#define num 5
    >
    >main ()
    >{
    >int vector[num], vector[num];
    >
    >
    >int incializar()
    >{
    >for (i=0;i<num;i++)
    >vector[i]=0;
    >}
    >
    >int GetData (int i, int vector[num])
    >{
    >for (i=0;i<num;i++)
    >cout<<"Entre los numeros"<<end1;
    >cin>>vector[i];
    >return (vector);
    >
    >float CalcMedia (float media, int suma )
    >{
    >for (i=0;i<num;i++)
    >suma = vector[i] + vector [i +1];
    >media = float (suma) / num;
    >return (media);
    >}
    >
    >float DesviacionEstandar (float vector[num], float vector2[num],float sum,float
    >de)
    >{
    >for (i=0;i<num;i++)
    >vector2[i]=vector [i] - media;
    >vector2[i]=pow(vector2[i],2);
    >sum=vector2[i] + vector2[i+1] /num;
    >de=sqrt(sum);
    >return(de)
    >}
    >
    >}
    >


    Without seeing the compile error, I'm guessing here, but both of your vectors
    in main( ) have the same name.

  3. #3
    sam Guest

    Re: Error in program


    Hi

    Thanks for your help! But I called my girlfriend and she told me that she
    has changed the names of th vector and the still having the same probrem.
    She isnt in front of her computer so I dont know the compiler error. Marc,
    can you see any other error? Thanks a lot!



    "Samuel" <pr2004@hotmail.com> wrote:
    >
    >Hi
    >I am a med student trying to help his girlfriend with a C++ program. I read
    >a little bit of nomenclature trying to find the error. This program is supposed
    >to calculate the standard deviation. Please help me! There is a copy of

    the
    >program...is a very very short one.
    >
    >Thank you!
    >Sam
    >pr2004@hotmail.com
    >
    >#include <stdio.h>
    >#include <iostream.h>
    >#include <math.h>
    >#define num 5
    >
    >main ()
    >{
    >int vector[num], vector[num];
    >
    >
    >int incializar()
    >{
    >for (i=0;i<num;i++)
    >vector[i]=0;
    >}
    >
    >int GetData (int i, int vector[num])
    >{
    >for (i=0;i<num;i++)
    >cout<<"Entre los numeros"<<end1;
    >cin>>vector[i];
    >return (vector);
    >
    >float CalcMedia (float media, int suma )
    >{
    >for (i=0;i<num;i++)
    >suma = vector[i] + vector [i +1];
    >media = float (suma) / num;
    >return (media);
    >}
    >
    >float DesviacionEstandar (float vector[num], float vector2[num],float sum,float
    >de)
    >{
    >for (i=0;i<num;i++)
    >vector2[i]=vector [i] - media;
    >vector2[i]=pow(vector2[i],2);
    >sum=vector2[i] + vector2[i+1] /num;
    >de=sqrt(sum);
    >return(de)
    >}
    >
    >}
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center