//pgm to find the sum and average of numbers within a limit
#include<iostream.h>
#include<conio.h>
void main()
{
float i,a,b,sum,average;
clrscr();
cout<<"enter the starting number";
cin>>a;
cout<<"enter the ending number";
cin>>b;
sum=0;
for(i=a;i<=b;i++)
sum=sum+i;
average=sum/((b-a)+1);
cout<<"sum="<<sum<<endl;
cout<<"average="<<average;
getch();
}
Please Click on ADS!!
Please Click on the above ads given by GOOGLE , so that I can maintain my blog!!
Tuesday, August 31, 2010
Subscribe to:
Post Comments (Atom)

0 comments:
Post a Comment