SOURCE CODE OUTPUT
#include<iostream>
using namespace std;
int main()
{
long sum=0,n,y=1,x;
cout<<"Enter the value of x ";
cin>>x;
cout<<"Enter the value of n ";
cin>>n;
for(int i=1;i<=n;i++)
{
if(i%x!=0)
{
cout<<i<<" ";
sum+=i;
}
}
cout<<endl<<"Sum "<<sum<<endl;
return 0;
}
using namespace std;
int main()
{
long sum=0,n,y=1,x;
cout<<"Enter the value of x ";
cin>>x;
cout<<"Enter the value of n ";
cin>>n;
for(int i=1;i<=n;i++)
{
if(i%x!=0)
{
cout<<i<<" ";
sum+=i;
}
}
cout<<endl<<"Sum "<<sum<<endl;
return 0;
}
Any questions regarding to program please write in comments.
No comments:
Post a Comment