0 like 0 dislike
7.2k views

Please write a program receive 2 sets of two-dimensional arrays: a[ ][ ] and b[ ][ ]; size 3*3. Then add a value of each element from a to b for example: a[0][0] + b[0][0], a[0][1] + b[0][1] and so on. Finally, output the summation of each addition.

For more information: http://pipls.net/41053/multi-dimensional-arrays-in-c-language

Input 1

1 2 3
4 5 6
7 8 9
1 1 1
1 1 1
1 1 1

Output 1

1 2 3
4 5 6
7 8 9
1 1 1
1 1 1
1 1 1
2 3 4
5 6 7
8 9 10

Input 2

1 1 1
0 0 0
1 1 1
2 2 2
2 2 2
2 2 2

Output 2

1 1 1
0 0 0
1 1 1
2 2 2
2 2 2
2 2 2
3 3 3
2 2 2
3 3 3

 

[Exercise] Coding (C) - asked in Chapter 4: Arrays by (5.9k points)
ID: 41054 - Available when: Unlimited - Due to: Unlimited
| 7.2k views

18 Answers

0 like 0 dislike
Hidden content!
#include ** **** * *
*** * ** ** * *
***** **
int main () {

* * * ****** * * an array with 5 rows and 2 *
** * * **** ** * a[3][3] = { {0,0,7}, {1,2,3}, *
** ***** ** i, j;
***** **
** ** * * ** output each array * value */
** * *** * * * ( i = 0; i < 3; i++ ) {

*** ** *** * * * * * * **** * ( j = 0; j < 3; j++ ) {
** * * * * * *** * * * * ** ** ** *** ** ** * **** **** ** ** * );
* ** ** * * ** * ** * ****** ***
* * ** ****** * * * **** * ** * ** * * * ** *
* * **** *** * **
***** * * **
*** * * * * b[3][3] = { * * * * * *** *
* *** * * **** * output each array *** value */
* * * * * * ** * ( i = 0; i *** 3; i++ ) {

* *** ** * ***** * * **** *** ** ( j = 0; j < 3; j++ ) {
** **** * * * * *** * * ** **** * ** * * ** * * **** ** ** ** * * * );
** * * * * ** ******** * **** * *
** ** * * ** * * *** *** * * *** ** * ***** *
*** ** * ** *** * *
* *** ** * **
*** ** * * *** ** ** ** *
* ** * *
* *** ** ** ** * output each array * * * * value */
* * * * ** * ** ( i = 0; i < 3; i++ ) {

* ***** * * ** ** * ** * * ** * * ** * ( j = 0; j < 3; j++ ) {
* * * * * * **** * * * *** * = a[i][j] + **
* **** * * ***** ** *** ***
* * * ***** ***** *** **** *
* * * * * **** * * *** *** ** * * ( i = 0; i * 3; i++ ) {
* ** * ** * * * ** * **** * * ( j = 0; j *** * 3; j++ ) {
* * * ** ** ** ** *** * * * ******* ** * * *** * *
* * ** * ***** **** ** **
** * *
}
* ** **** * ** * * * 0;
}
80/100 answered by (221 points)
edited by
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
** * * * ** * * ** array[3][3], array2[3][3];
* * ** * *** * * ** ** rows = 3;
* * * ** * ** * ** ** * ** columns = 3;
** *** * *** * * **

* * * *** *** ** i = 0; i < rows; i++){
* ** * ** ** **** ** ****** *** * ** * ** j = 0; j < columns; j++){
** **** * * ***** *** * * **** * *** ** * ** ****
* * *** * *** **** ** ** ** * ** * * ** * * ** * ** ** * * * * * * **** * *
* * * * * * * * **
** ***** * ** *** *
** * * **** *** * * ** ** * i = 0; i < rows; i++){
** **** ** *** * * *** * ** * ** ** ** * * j = 0; j < columns; j++){
*** **** * ** ****** **** * *** ***** *** * *** * * *** * **
* ** * * * **** * ** **** * **** * ** * ** * * * * ** * * * ** ** * * *
*** ** * **** ** * *
** * * * * **
** * ** ** ** ***** **** i = 0; i < rows; i++){
** ** * * ** * * * ** * ** * * ***** **** j = 0; j < columns; j++){
* ** ** ** ** ***** * *** ** ** *** ** ** * ***** * * ****** *** ** ", array[i][j]+array2[i][j]);
* **** * ** ** * **** * * ** * * ** * * ** ** * * *** * ** * * * * * **** * ***
* * *** ****** * ** * * ** * * * ***** * ** **** * *
******** * * *** ****
* ** *** ** * ** **
** ********* ** * *
* ** ** * ***** * * * *** * * * * *  
  return 0;
}
100/100 answered by (273 points)
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Wrong output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
    int a[3][3];
    int b[3][3];
    
    for(int i=0;i<3;i++){
* ** ** * * * * **** ** * * * ** * ** * ** * ****** * * * ** j=0;j<3;j++){
**** * * * ** * *** **** * ** ** **** * **** ******** ** * * * *** ****** * * * ** * ** ***** * * *** *** * *** * * *** *
* * ** * *** ** ** * * * ** ** *** ** * * * * * * ** *** ** ******* ** * ** * *** * * * **** ******* * *
** ** * * * * * *** *** * ** *** ** ** * ***** ******* * * * * **** * * *** * * ** * * *
    for(int i=0;i<3;i++){
* * ** ** ** * ***** * *** ** **** * ** * *** ****** * ** ** ** *** ** ** j=0;j<3;j++){
* **** * **** * * *** ** * *** * ** * **** * ** ** ** ****** ******** * * * ** *** ** *** *** ****** ** *** ** ** * ** * *** *** * * * * * * *
* * ** ***** *** * *** * * * ***** **** ** ** * **** *** * ** ** * ** * *** ** **** *** * * **** *** *****
**** ** * * * * * ******* ** * * * ** * ***** ** * ***** *** **** * * * *** *** * * * *
    
  for(int i=0;i<3;i++){
* * ** * * * ***** * * * * * *** *** * ** * * ****** *** * *** **** j=0;j<3;j++){
*** * * * * ** * * * ** * *** *** * * * ****** ***** * * ** * *** * * ** ***** * * * ***** * *** *** ****** ",a[i][j]+b[i][j]);
******* *** * **** * * * * * ** ** * * * ****** * * ** ***** *** ** * **** ** ***** *** ** *** * ** * ** * ***
* * * * *** ** * *** *** *** *** **** *** * ******* ** ** * * ****** * * *** ** ** * ***** ******* ***
** *** * ** * * * ** * ** * ************ ** ** * * * * * * * * ** * ***** **** * * ** * * * * * ***** * * ** ** * **
***** * ** *** * * * ** * * * ** * * * ****** * ** * * * * ** *** * ** * ** * **** ** * ** * *
 system("PAUSE");
  return 0;
}
100/100 answered by (290 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Wrong output
0 like 0 dislike
Hidden content!
#include ****** * ** *
 
int main()
{
***** *** *** ** * a, b, * *** * * * ** * * *
 
* *** ** ** ** *** (a = 0; a < 3; a++)
* * * * * *** *** * ** (b = 0; b < 3; b++)
**** ** * * * **** *** ** * * * * ** **** ****** * ****** *** * ** ** ** * * * ****
***
** **** ** ** ** * *** (a = 0; a < 3; a++)
** ** * * * ** * * * ******** * (b = 0 ; b < 3; b++)
**** ****** ** ** ****** * ***** *** * * ***** ** * * * * **
** *
 
* * ** *** * * (a = 0; a < 3; a++) {
* * ** * ***** ** * * * * * * * (b = 0 ; b < 3; b++) {
* *** * *** **** * ** * ** * *** * ******** * * ** *** = first[a][b] + * *
***** ** ** ** ** ** * ** * * * ** ***** ** * **** **** ** **** ", * **
* ** ** ***** ** *** ***** * ***** *
* * * * * ** *** * ** * * ** * * *** * ***
* * *** ** * **
* * * **** * * ** *
***** * * **** 0;
}
100/100 answered
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Wrong output
0 like 0 dislike
Hidden content!
#include * ** **** *
 
int main()
{
** * * * ** a, b, ** ** * * * * ****
 
* * *** ** * ** *** (a = 0; a < 3; a++)
* ** * *** *** ** *** ** * ** (b = 0; b < 3; b++)
**** * * *** * **** * * ******** ****** ** * * **** ** * * ** * * ** *
*
* ******** * * * (a = 0; a < 3; a++)
* * **** * * ** * * * * * * *** (b = 0 ; b < 3; b++)
*** * * * **** * * *** * ** ** ** ** **** ** ** * ** * ** * ** * *
**** **
 
* * * ** ***** (a = 0; a < 3; a++) {
* * * ******* ** * ** * * * * ** (b = 0 ; b < 3; b++) {
* * * ******** ** * * *** * ** *** *** ** ****** **** * = first[a][b] + **** * *
* * * * ** ** * *** ****** ** * * ** *** **** **** * * * * ", *** ****
* * ** *** ** * * * ** * * * *
* * ** * ** *** **** * * ** * **** ** * * *
* * * * * * *
* ** ** ** * * *
*** * ** * ** * 0;
}
100/100 answered by (192 points)
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Wrong output
0 like 0 dislike
Hidden content!
#include * *** ****
 
int main(int argc, char *argv[])
{
** ** ** ** *** ** a, b, * ** * **** ** ** * *
 
*** **** * ** (a = 0; a < 3; a++)
*** *** * *** ** * ****** ** ** (b = 0; b < 3; b++)
* * * ******* * * ***** * * ** * *** ****** * *** * * ****** ** * * *
* ** *
* * * *** * * (a = 0; a < 3; a++)
* * **** *** * * * ** ** *** ** (b = 0 ; b < 3; b++)
* * ** *** * **** * ** * * * * ** * * ****** * * * * ** * *** * * **
* ****
******
* * *** * * ***** * (a = 0; a < 3; a++) {
**** ** *** ** *** * ****** (b = 0 ; b < 3; b++) {
**** ** * * ** * * * * ** * ** * ****** ***** *** = * * + ** *
* * *** * * ** **** * *** * ** **** ** *** *** *** ** ", **** * *
* ** * * ** * * ** * *** ** * ** *
** * ** ** **** * ** * ***** *** **** *
** * * * *** *
** *** **** **
* * ****** *** 0;
}
100/100 answered by (254 points)
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Wrong output
0 like 0 dislike
Hidden content!
#include * * *
*** * *
int main()
{
* * * ** * *** * a, b,
** ***** **** * ** *
* *** ** ** ** * * ***
* ** **** ** * **
 
** **** * * * (a = 0; a < 3; a++)
* ** ******** * **** ** * **** *** **** (b = 0; b < 3; b++)
* ** * ***** * *** ** * *** * * ****** * *** ****** * **** * * ******* **
* *****
* * * * * ***** * * (a = 0; a < 3; a++)
* * * *** *** ** ** ** **** **** * ** (b = 0 ; b < 3; b++)
* ***** ** * ** * * *** * * * * * ** * * **** * ** * * ** *** ** * ** *
 
 
** * ** * * *** *** (a = 0; a < 3; a++) {
*** ** *** * *** *** *** * * **** (b = 0 ; b < 3; b++) {
** * * * * ** ** * **** **** * ** ** *** *** * * ** = f[a][b] + g[a][b];
*** * *** * ** ***** ** ** * * ** * * * ** * * * * ** *** ***** s[a][b]);
*** * * **** ** *** * *** *****
** *** ** ** ** * * ** **** * * *** ** * * ** *
*** * ** ** * *
** * * * *
* ** * ******* * 0;
}
100/100 answered by (220 points)
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Wrong output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
    int a[3][3];
    int b[3][3];
    
* * *** *** * *** * ** ** i=0;i<3;i++){
* * * * * *** * * * ** ****** *** **** **** * ****** * **** ** j=0;j<3;j++){
* * ** * * **** ****** * *** ***** **** * * * ** * * * * *** * **** ** ******* ******* * * * * * * *** * * *** * * * ** ** * * ** &a[i][j]);
** ***** * ** * *** * * ** **** * ** **** * ** * *** *** ** *** *** * ****** * * ****** ** * **** **** ** *
* *** ** * * ***** * * ** ** * * * * ** ** *** ** * * * **
    
**** ****** ** *** * ** *** * i=0;i<3;i++){
**** *** *** * * * * ** ** * * * ** * * * * ** ** * j=0;j<3;j++){
* * * *** * *** * ******* *** * * *********** * ** * * * * ** * ***** * *********** * ****** * *** * **** *** *** ** ** &b[i][j]);
**** * * * ** ***** * * *** ** * ** ****** * * *** *** ** ** ** * **** *** * ***** * *** * * * ****** *
**** ******* * ** * * * * ** * ** * * *** ** *** **** * * * *
* *** * * *** ** * * ** ** * ** ** * **** * * * ** ** * * * ** * * ** * * *** * * ** * **** * * ** * **
    for(int i=0;i<3;i++){
* ** ** * * * * * * * * * *** **** * * **** * *** ** * * * * * j=0;j<3;j++){
*** **** ** * * **** ** * * *** ** * * * ** ** *** * * * ***** ** ** **** *** ** * * ** ** ** ***** * **** * ** ** ", a[i][j]+b[i][j]);
* ** **** *** ** * **** * *** * *** * **** * ****** ** ** * * ** ** * * * **** ** ** * * * * * * * * ** ** **
* * * ** * ** * ** * **** * ** ** * * * ** * * * *** ******* * ** ** ** *** *** * ** * *** **** * ******* * * * ** ** * *** * **
* * **** * ** ** ** * * * * * ** * * ** ** **** *** **** * ***
  
* * ** * ** ** * * * * * ***  
  return 0;
}
100/100 answered by (271 points)
edited by
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Wrong output
0 like 0 dislike
Hidden content!
#include *** *
 
int main()
{
* ** **** * * a, b, * *** * * * * * **
 
* ** **** * (a = 0; a < 3; a++)
**** * * * ** ** **** * * * (b = 0; b < 3; b++)
* *** ** *** * *** ***** *** * * ** * *** **** * * ** * ** ** * **
* *
** * ** * * * * * (a = 0; a < 3; a++)
* * ** * ** * **** * * **** ** * ** (b = 0 ; b < 3; b++)
* * * * ** * ******* * ** ** ** * * ** *** * ** * ** * ** ** * ** ** **
* * *
 
*** *** * * * ** * * (a = 0; a < 3; a++) {
** ***** **** * *** * ** ** ** * * (b = 0 ; b < 3; b++) {
* * ** ** ** ** * * * ***** ***** ** ** * ** * *** = first[a][b] + ** *** *
* * * ** * **** *** * ** ** * * * ** *** *** * * * * * ****** ", ** **
* * * *** * *** * ***** ** * *
**** ****** *** * ** * **** * ** ** * ** **** * ** **
** * * * * * **
** ** * * ** * * **
** * *** ** ** * 0;
}
100/100 answered by (153 points)
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Wrong output
0 like 0 dislike
Hidden content!
#include * * ** **
 
int main()
{
* * * * * * a, b, *** * * * *** * ******
 
*** **** * * * * * (a = 0; a < 3; a++)
* * * **** * * * * * * * ** ** * (b = 0; b < 3; b++)
* * ***** * ****** ** * ** * * ** *** **** *** * * * ** ****** * ** * **
* * ***
* * * ** * **** (a = 0; a < 3; a++)
* * *** ** * * ** *** * ***** (b = 0 ; b < 3; b++)
***** * * * * * * * ** * *** **** * * * *** * * ** **** * * * ***** *****
** ** (a = 0; a < 3; a++) {
* * * * ****** * * ** ********* (b = 0 ; b < 3; b++) {
*** * *** * *** ** *** * ** ** ***** *** * = first[a][b] + * **
* * ** ** * * ** * *** * * ** *** * ****** * *** * ", ** *
* * ** * ***** * * * ** ** *
* * **** ** ** ** *** *** *** * * ** **
** *** * ** ***
*** * * **** ** *** * *
* * ** * 0;
}
100/100 answered by (283 points)
0 0
prog.c: In function 'main':
prog.c:22:3: error: expected declaration or statement at end of input
   return 0;
   ^~~~~~
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Wrong output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:104.23.197.64
©2016-2026

Related questions

0 like 0 dislike
17 answers
[Exercise] Coding (C) - asked Dec 7, 2017 in Chapter 4: Arrays by nat236919 (5.9k points)
ID: 35804 - Available when: Unlimited - Due to: Unlimited
| 6.1k views
0 like 0 dislike
0 answers
[Resource] asked Jan 5, 2018 in Chapter 4: Arrays by nat236919 (5.9k points)
ID: 41053 - Available when: Unlimited - Due to: Unlimited
| 13 views
0 like 0 dislike
20 answers
[Exercise] Fill in the blank - asked Dec 15, 2017 in Chapter 4: Arrays by nat236919 (5.9k points)
ID: 37578 - Available when: Unlimited - Due to: Unlimited
| 3.6k views
0 like 0 dislike
46 answers
[Exercise] Coding (C) - asked Dec 15, 2017 in Chapter 4: Arrays by nat236919 (5.9k points)
ID: 37580 - Available when: Unlimited - Due to: Unlimited
| 11.4k views
0 like 0 dislike
18 answers
[Exercise] Fill in the blank - asked Dec 7, 2017 in Chapter 4: Arrays by nat236919 (5.9k points)
ID: 35798 - Available when: Unlimited - Due to: Unlimited
| 3.2k views
12,783 questions
183,442 answers
172,219 comments
4,824 users