===========================================================================
CODING
#include<all.h>
void main()
{
clrscr();
double q,sum=0,N=0;
int n,i;
cout<<"\nEnter number: ";
cin>>n;
cout<<"\n";
for(i=1;i<=n;i++)
{
cout<<"(";
for(q=1,N=0;q<=i;q++)
{
N=q+N;
if(q<i)
cout<<q<<" + ";
else
cout<<q;
}
sum=N+sum;
if(i<n)
cout<<") + ";
else if(i==n)
cout<<") = ";
}
cout<<sum;
getch();
}
CODING
#include<all.h>
void main()
{
clrscr();
double q,sum=0,N=0;
int n,i;
cout<<"\nEnter number: ";
cin>>n;
cout<<"\n";
for(i=1;i<=n;i++)
{
cout<<"(";
for(q=1,N=0;q<=i;q++)
{
N=q+N;
if(q<i)
cout<<q<<" + ";
else
cout<<q;
}
sum=N+sum;
if(i<n)
cout<<") + ";
else if(i==n)
cout<<") = ";
}
cout<<sum;
getch();
}
===========================================================================
No comments:
Post a Comment