Verifying column and line counts I have created this simple code:


  For the size of an array with 2 values (n and m), verify if n and m are >= 1. m = width and n = height.


The code works but I'm sure it isn't optimized.

printf("Number of ligns.");
scanf("%d",n);
printf("Number of columns.");
scanf("%d",m);


if(*n &gt;= 1)
{
    if(*m &gt;= 1)
    {
        printf("Number of ligns : %x, Number of columns : %x \n", *n, *m);
    }
    else
    {
        while(*m &lt; 1)
        {
            printf("Error, number of colums/ligns &lt; 1. \n");
            scanf("%d",m);
        }
        printf("Number of ligns : %x, Number of columns : %x \n", *n, *m);
    }
}
else
{
    while(*n &lt; 1)
    {
        printf("Error, number of colums/ligns &lt; 1. \n");
        scanf("%d",n);
    }
            if(*m &gt;= 1)
    {
        printf("Number of ligns : %x, Number of columns : %x \n", *n, *m);
    }
    else
    {
        while(*m &lt; 1)
        {
            printf("Error, number of colums/ligns &lt; 1. \n");
            scanf("%d",m);
        }
        printf("Number of ligns : %x, Number of columns : %x \n", *n, *m);
    }
}
You should provide a compiling code. I'll assume that n and m are int, but you should have added their declaration.


You should use explicit names for variables. n is a line count, so call it line_count. m is column_count.
You should check the return values of scanf to be sure you handle gracefully EOF and bad input.
You print "Error, number of colums/ligns &lt; 1. \n" every time, so the user can't know if it's the lines or the columns or both that are &lt; 1.
The english word is "lines", not "ligns".
Your checks are too complicated and redundants. The entire if/else block can be replaced by this:

while(*line_count &lt; 1)
{
    printf("Error, number of lines &lt; 1. \n");
    scanf("%d", line_count);
}


while(*column_count &lt; 1)
{
    printf("Error, number of colums &lt; 1. \n");
    scanf("%d", column_count);
}

printf("Number of lines : %x, Number of columns : %x \n", *line_count, *column_count);