Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Linear Algebra and the C Language/a057

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

__NOTOC__ Install and compile this file in your working directory. /* ------------------------------------ */ /* Save as : addc.c */ /* ------------------------------------ */ #include "v_a.h" /* ------------------------------------ */ int main(void) { double a[R3*C3] = { 1, 2, 3, 2, 2, 3, 3, 2, 3}; double **A = ca_A_mR(a,i_mR(R3,C3)); double s = 0.; int c1 = C0; int c2 = C0; clrscrn(); s = -2.; c1 = C1; c2 = C2; printf(" A :"); p_mR(A,S5,P0,C6); printf(" Multiply C%d by %+.0f, \n",c1,s); printf(" then add %+.0fC%d and C%d \n",s,c1,c2); printf(" put the result into C%d \n\n",c2); printf(" A : \n"); p_mR(addC_mR(A,s,c1,c2),S5,P0,C6); stop(); clrscrn(); s = -3.; c1 = C1; c2 = C3; printf(" A :"); p_mR(A,S5,P0,C6); printf(" Multiply C%d by %+.0f, \n",c1,s); printf(" then add %+.0fC%d and C%d \n",s,c1,c2); printf(" put the result into C%d \n\n",c2); printf(" A : \n"); p_mR(addC_mR(A,s,c1,c2),S5,P0,C6); stop(); f_mR(A); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ Multiplies c1 by s add sc1 at c2: Screen output example: A : +1 +2 +3 +2 +2 +3 +3 +2 +3 Multiply C1 by -2, then add -2C1 and C2 put the result into C2 A : +1 +0 +3 +2 -2 +3 +3 -4 +3 Press return to continue. A : +1 +0 +3 +2 -2 +3 +3 -4 +3 Multiply C1 by -3, then add -3C1 and C3 put the result into C3 A : +1 +0 +0 +2 -2 -3 +3 -4 -6 Press return to continue.