Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Discussion > The Lounge > returning array value from the functions in c language

Reply
Thread Tools

returning array value from the functions in c language

 
 
konvictx konvictx is offline
Junior Member
Join Date: May 2012
Posts: 1
 
      05-09-2012
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????
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
returning none when it should be returning a list? randomtalk@gmail.com Python 11 05-02-2006 10:26 AM
Functions returning pointers JS C++ 9 03-16-2005 07:49 PM
Returning const reference value from functions Sree C++ 3 06-25-2004 11:50 AM
please help me in distinguish redefining functions, overloading functions and overriding functions. Xiangliang Meng C++ 1 06-21-2004 03:11 AM
returning value in assembly language. R.Sudharsan C++ 0 08-02-2003 01:46 PM



Advertisments