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 odd and even nos between 1 and 10

//pgm to find the sum and avg of odd and even nos between 1 and 10
#include<iostream.h>
#include<conio.h>
void main()
{
    int i=1;
    float sumo,sume, avgo,avge;
   sumo=sume=0;
   while(i<=10)
   {
       if(i%2==0)
          sume=sume+i;
      else
          sumo=sumo+i;
      i++;
   }
   avgo=sumo/5;
   avge=sume/5;
   cout<<"sume="<<sume<<endl<<"sumo="<<sumo<<endl;
   cout<<"avgo="<<avgo<<endl<<"avge="<<avge;
   getch();
}

0 comments:

Post a Comment

free counters