C++ program that display the series of odd Number from I to F i.e (from initial value to final value) define by a user
#include <iostream>
using namespace std;
int main()
{
int f,i,sum=0;
cout<< "Enter the intial value : ";
cin>>i;
cout<< "Enter the final value : ";
cin>>f;
for(int n=1;n<=f;n+=2){
cout<<n<<endl;
sum+=n;
}
cout<< "the sum of number from "<<i<<" to "<<f<<" = "<<sum<<endl;
return 0;
}
No comments:
Post a Comment