Search This Blog

Thursday, October 13, 2011

Write a program to read three real Num x,y,z and evaluates their avg. the Num read in a function Readdata() and Getavarage() evaluates the data and returns the value to main()

   1:  #include<stdio.h>
   2:  #include<conio.h>
   3:  void readdata();
   4:  float getaverage();
   5:  float x,y,z;
   6:  void main()
   7:  {
   8:  float average;
   9:  readdata();
  10:  average=getaverage();
  11:  printf("Average = %f\n",average);
  12:  getch();
  13:  }
  14:  void readdata()
  15:  {
  16:  printf("Enter x,y and z:\n");
  17:  scanf("%f%f%f",&x,&y,&z);
  18:  }
  19:  float getaverage()
  20:  {
  21:  float av;
  22:  av=(x+y+z)/3;
  23:  return(av);
  24:  }

No comments:

Post a Comment