Here is a very simple example to get you started. This is for addition (not multiplication or exponentiation), and it’s for 3-digit numbers, not thousands. But it demonstrates the basic idea of holding each digit in one element of an array. When you add (or subtract, or multiply) numbers like these in a computer program, you can use exactly the same techniques you learned for doing arithmetic in school.
#include <stdio.h>
int main()
{
int a[10], b[10], c[10];
a[2] = 4; a[1] = 5; a[0] = 6; /* 456 */
b[2] = 7; b[1] = 8; b[0] = 9; /* 789 */
int partialsum = a[0] + b[0];
c[0] = partialsum % 10;
int carry = partialsum / 10;
partialsum = a[1] + b[1] + carry;
c[1] = partialsum % 10;
carry = partialsum / 10;
partialsum = a[2] + b[2] + carry;
c[2] = partialsum % 10;
carry = partialsum / 10;
c[3] = carry;
printf("%d%d%d%d\n", c[3], c[2], c[1], c[0]);
}
The biggest limitation in this program is that it’s hardwired to work with 3-digit numbers and a 4-digit sum. The first improvement you might like to try to make would be to keep count (perhaps in additional variables) of the actual number of digits in each number.
See also this question and its answer, and its linked duplicates.
solved How can I compute a very big digit number like (1000 digits ) in c , and print it out using array