returning array value from the functions in c language

Discussion in 'The Lounge' started by konvictx, May 9, 2012.

  1. konvictx

    konvictx

    Joined:
    May 9, 2012
    Messages:
    1
    Code:
    #include<stdio.h>
    #include<conio.h>
    float average(float[],float );
    float highest(float[],float );
    float lowest(float[], float );
    void main (void)
    {
    float temper[15];
    float x,n, y, z;
    int  day;
    clrscr();
    printf("enter the no.days to read temperature for=\n");
    scanf("%d",&n);
    for(day=0; day<n; day++)
     {
     printf("temperature for day%d=",day+1);
     scanf("%f",&temper[day]);
     }
    x=average(temper,n);
    printf("average temperature is=%.2f\n",x);
    y=highest(temper,n);
    printf("highest temperature is=%.2f\n",y);
    z=lowest(temper,n);
    printf("lowest temperature is=%.2f\n",z);
    getche();
    }
    
    float average(float temper[],float n)
    {
    int sum=0.0,x;
    float average;
    for(x=0; x<n; n++)
     sum+=temper[x];
     average=sum/n;
     return (average);
    }
    
    float highest(float temper[],float n)
    {
    float highest;
    int y;
    highest=temper[0];
    for(y=0; y<n; y++)
    if(highest<temper[y])
    highest=temper[y];
    return(highest);
    }
    
    float lowest(float temper[],float n)
    {
    float y,lowest=temper[0];
    for(y=0; y<n; y++)
    if(lowest>temper[y])
    lowest=temper[y];
    return(lowest);
    }
    
    
    
    hi my program is not returning value of average minimum and maximum... what can i do now????
     
    konvictx, May 9, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. uv2003
    Replies:
    4
    Views:
    627
    =?Utf-8?B?U2Vhbg==?=
    Jun 23, 2005
  2. philip007
    Replies:
    1
    Views:
    607
    jcottingim
    Jan 31, 2006
  3. amrutha0303
    Replies:
    0
    Views:
    989
    amrutha0303
    Aug 3, 2010
  4. amrutha0303
    Replies:
    0
    Views:
    2,140
    amrutha0303
    Aug 3, 2010
  5. Neal
    Replies:
    0
    Views:
    1,494
Loading...

Share This Page