/*Before seeing the code solution make sure that you have tried enough. Don’t copy- paste the whole code. Find out the logic. If you face any trouble, just inform me in comment.*/
#include<stdio.h>
main()
{
int m,n,i,j=0;
while(1)
{
scanf("%d%d",&m,&n);
if(m<=0||n<=0)
{
break;
}
else if(m>n)
{
for(i=n,j=0;i<=m;i++)
{
j=j+i;
printf("%d ",i);
}
printf("Sum=%d\n",j);
}
else if(n>m)
{
for(i=m,j=0;i<=n;i++)
{
j=j+i;
printf("%d ",i);
}
printf("Sum=%d\n",j);
}
}
return 0;
}
//Happy_Coding
#include<stdio.h>
main()
{
int m,n,i,j=0;
while(1)
{
scanf("%d%d",&m,&n);
if(m<=0||n<=0)
{
break;
}
else if(m>n)
{
for(i=n,j=0;i<=m;i++)
{
j=j+i;
printf("%d ",i);
}
printf("Sum=%d\n",j);
}
else if(n>m)
{
for(i=m,j=0;i<=n;i++)
{
j=j+i;
printf("%d ",i);
}
printf("Sum=%d\n",j);
}
}
return 0;
}
//Happy_Coding
No comments:
Post a Comment