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