#include<iostream>
using namespace std;
int main(){
int n;
cout<<"Enter the range\n";
cin>>n;
int sum=0;
for(int i=0;i<=n;i++){
cout<<i<<" ";
sum+=i;
}cout<<endl;
cout<<"The sum between given range is-> "<<sum<<endl;
return 0;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter