There are three arrays: I enter the number in the first, for example, 12345, in the second I enter the number 22222, respectively, in the third array I write down the result of the addition of these two numbers, as if it were calculated on a piece of paper (well, addition in a column) there is an error in it, of course)

#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<conio.h> void main(void) { int A[5], B[5], C[10], i = 0, j = 0, k = 10; for (i = 0; i < 5; i++) { A[i] = getchar(); } for (i = 0; i < 5; i++) { B[i] = getchar(); } for (i = 4; i >= 0; i--) { for (j = 4; j <= i; j--) C[k] = A[i] + B[j]; k = k - 1; } for (i = 0; i<10-k; i++) { printf("%d", C[i]); } _getch(); } 

Here is another question: how useful it is to enter digit digits through getchar () character-wise, otherwise you will have to constantly press Enter after entering each digit. And is it possible to store a minus sign in an array,

  • one
    To begin with, nullify the arrays, enter ... = getchar() - '0'; (get a binary representation of decimal digits ), be sure to check and if you get the wrong number, go to the next step. And when adding, consider the transfer to the senior level. And by the way, nested loops when adding is an error. - avp
  • @ avp, and then how to add up without a nested loop? - Elvin
  • one
    You add, not multiply, so in one, from the youngest to the eldest. Just do not forget that the length of the result can turn out to be one digit more than the length of the items - avp

0