C++ Programs & Stuffz

Nothing like anything!!!

Please Click on ADS!!

Please Click on the above ads given by GOOGLE , so that I can maintain my blog!!

Tuesday, August 31, 2010

Find the sum and avg of any n nos

//pgm to find the sum and avg of any n nos
#include<iostream.h>
#include<conio.h>
void main()
{
    int i=1,n,x;
   float sum,avg;
   sum=0;
   cout<<"enter the value of n";
   cin>>n;
   cout<<"enter the nos";
   while(i<=n)
   {
       cin>>x;
      sum=sum+i;
      i++;
   }
   avg=sum/n;
   cout<<"sum="<<sum<<endl;
   cout<<"avg="<<avg;
   getch();
}

0 comments:

Post a Comment

free counters