In: Computer Science
In C
1- Use nested for loops to create an addition lookup table. Fill in an array and print out the following table showing the sum of the row and column numbers 0-9.
0 1 2 3 4.. <- column numbers
1 2 3 4 5..
2 3 4 5 6.. <- These nos. = Row + Column
3 4 5 6 7.. <- for example 7 = 3 + 4
4 5 6 7 8.. ...
^Row numbers
2- use
A hexadecimal version 16x16 table 0-F. Use print specifier %x to print numbers in hex instead of decimal.
(1)
C Program:
/* C Program that prints addition look up table */
#include <stdio.h>
#include <stdlib.h>
//Main program
int main()
{
    int i,j;
printf("\n");
    //Printing starting row (Row number)
    for(i=0; i<=9; i++)
    {
        //Printing row
number
        printf(" %-4d ",
i);
    }
    //Iterating over remaining rows
    for(i=1; i<=9; i++)
    {
        //Printing row
number
        printf("\n %-4d ",
i);
        //Iterating over
columns
        for(j=1; j<=9;
j++)
        {
           
//Printing column values
           
printf(" %-4d ", (i+j));
        }
    }
    printf("\n\n");
    return 0;
}
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sample Output:

_____________________________________________________________________________________________
(2)
/* C Program that prints hexadecimal numbers */
#include <stdio.h>
#include <stdlib.h>
//Main program
int main()
{
    int i, j;
printf("\n %4c ", '+');
    //Printing starting row
    for (i = 0; i < 16; i++)
    {
        //Printing row
        printf(" %4X ",
i);
    }
//Printing decimal and equivalent hexadecimal numbers
    //Printing rows
    for (i=0; i<16; i++)
    {
        //Printing row
        printf("\n %4X ",
i);
        for(j=0; j<16;
j++)
        {
           
//Printing value
           
printf(" %4X ", (i+j));
        }
    }
    printf("\n\n");
    return 0;
}
Sample Output:
