Subscribe For Free Updates!

We'll not spam mate! We promise.

Monday, 27 August 2012

C++ code to displaying sum of all numbers between any 2 inputs intigers




#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;
}

Socializer Widget By CodingLovers
SOCIALIZE IT →
FOLLOW US →
SHARE IT →

0 comments:

Post a Comment