DEV Community

legend
legend

Posted on

c program for counting numbers

#c

hello everyone i've been writing this program for counting numbers and i want to print it from certain starting point to certain extent

//counting machine
#include<stdio.h>

int main()
{
    int q1,q2,q3,q4,q5,q6,c=0,NOL,st;
    printf("enter the number from where to how much combinations you want: ");
    scanf("%d %d",&st,&NOL);
    q1=q2=q3=q4=q5=q6=0;
    for(q1=0;q1<=60;q1++)
    {
        for(q2=0;q2<=60;q2++)
        {
            for(q3=0;q3<=60;q3++)
            {
                for(q4=0;q4<=60;q4+=2)
                {
                    for(q5=0;q5<=60;q5+=5)
                    {
                        for(q6=0;q6<=60;q6+=5)
                        {
                            c++;
                            if((q1+q2+q3+q4+q5+q6)==60 && c>=st && (q4/2)<=5)
                            {
                                if(c<=NOL)
                                {
                                    printf("%d %d %d %d %d %d \n",q1,q2,q3,q4,q5,q6);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)