Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
690 B
2
Indexable
Never
#include <stdio.h>
int main()
{
    int m,n,sum;
    for (int i = 1; i <=3; i++)
    {
        sum=0;
        scanf("%d %d",&m,&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);
        }
        
        
    }
    
    

    return 0;
}