Saturday, 15 September 2012

c program for mean using array

For beginners
{I am going write the c program but before you need a c compiler(software).there are a lot of compilers(software) for windows 7  like Code::Blocks,dev c++ Download dev c++ its free and install it in your computer.open  dev c++ go to file-->new-->source file.}


#include<stdio.h>
#include<conio.h>
main()
{
      int n,a[100],s=0,i;
      float mean;
      printf("\n enter the number of elements(only<100) \n");
      scanf("%d",&n);
      printf("\n enter the numbers\n");
      for(i=0;i<n;i++)
      {
                      scanf("%d",&a[i]);
                      s=s+a[i];
                      }
                      mean=(float)s/n;
                      printf("\n the mean = %f \n",mean);
                      getch();
                      }


For beginners
{After typing this program go to execute-->compile & run-->a window will pop-up-->give file name:(anything u like)-->save as type: c source files-->click save.}

IS IT HELPFIL? comment.

No comments:

Post a Comment