Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
816 B
4
Indexable
Never
#include <stdio.h>
int main()
{
    int m,n,sum;
    for (int i = 1; ; i++)
    {
        sum=0;
        scanf("%d",&m);
        scanf("%d",&n);
        if (m>n && m>0 && n>0)
        {
            for (int i = n; i <=m; i++)
            {
                printf("%d ",i);
                sum=sum+i;

            }
            printf("sum =%d\n",sum);
        }
        else if (n>m && m>0 && n>0)
        {
            for (int i = m; i <=n; i++)
            {
                printf("%d ",i);
                sum=sum+i;

            }
            printf("sum =%d\n",sum);
        }
        else if (n==m && m>0 && n>0)
        {
            printf("%d",n);
        }

        else if (m<=0 || n<=0)
        {
            return 0;
        }


    }



    return 0;
}