Write a Using For Loop Find The Sum Of Whole Numbers Given By User C++ Program
#include<iostream>
using namespace std;
int main()
{
int a,sum=0;
cout<<"Enter The Value =";
cin>>a;
for(int i=1; i<=a; i++)
{
sum=sum+i;
cout<<i<<"+";
}
cout<<endl<<"Sum Of The Whole Number ="<<sum<<endl;
}
No comments:
Post a Comment