#include<iostream.h>
#include<conio.h>
int main()
{
clrscr();
int s_num;
int e_num;
int sum=0;
cout<<"\nEnter starting number: ";
cin>>s_num;
cout<<"\nEnter ending number: ";
cin>>e_num;
cout<<"\nThe sum of integers from "<<s_num<<" to "<<e_num<<" is ";
for(; s_num<=e_num; s_num++)
{
sum +=s_num;
}
cout<<sum;
return 0;
}
0 comments:
Post a Comment