I need your help, i need a Turbo C code for this problem..
hope u'll help me guys.?
Your program will have a 3x3 array. The user will input the
sum of each row and each column. Then the user will input 3
values and store them anywhere, or any location or index,
temporarily in the array. Your program will supply the
remaining six (6) values and determine the exact location of
each value in the array.

Example:
Input: Sum of row 1: 6
Sum of row 2: 15
Sum of row 3: 24
Sum of column 1: 12
Sum of column 2: 15
Sum of column 3: 18
Value 1: 3
Value 2: 5
Value 3: 6

Output: Sum of Row
1 2 3 6
4 5 6 15
7 8 9 24
Sum of Column
12 15 18

Note: Your program will not necessary sort the walues in the
array


Thanks..



I need your help, i need a Turbo C code for this problem.. hope u'll help me guys.? Your prog..

Answer / Rashmi Tiwari

Here's a simple Turbo C code to solve the problem: (Note that this is an educational example, and you may need to optimize it for efficiency)nn```cn#include <stdio.h>nn#define ROW 3n#define COL 3nnint array[ROW][COL];nnvoid input_array(void);nvoid display_sums(void);nvoid calculate_remaining_values(void);nvoid find_locations(void);nnint main() {n input_array();n display_sums();n calculate_remaining_values();n find_locations();n return 0;n}nnvoid input_array(void) {n printf("Input the sum of each row:
");n for (int i = 0; i < ROW; ++i) {n int sum = 0;n for (int j = 0; j < COL; ++j) {n printf("row %d column %d: ", i + 1, j + 1);n scanf("%d", &array[i][j]);n sum += array[i][j];n }n printf("Sum of row %d: %d
", i + 1, sum);n }n printf("Input the sum of each column:
");n for (int j = 0; j < COL; ++j) {n int sum = 0;n for (int i = 0; i < ROW; ++i) {n sum += array[i][j];n }n printf("Sum of column %d: %d
", j + 1, sum);n }nn printf("Input three values temporarily in the array:
");n for (int i = 0; i < ROW; ++i) {n for (int j = 0; j < COL; ++j) {n int value;n printf("row %d column %d: ", i + 1, j + 1);n scanf("%d", &value);n array[i][j] = value;n }n }n}nvoid display_sums(void) {n for (int i = 0; i < ROW; ++i) {n int sum = 0;n for (int j = 0; j < COL; ++j) {n sum += array[i][j];n }n printf("Sum of row %d: %d
", i + 1, sum);n }nn for (int j = 0; j < COL; ++j) {n int sum = 0;n for (int i = 0; i < ROW; ++i) {n sum += array[i][j];n }n printf("Sum of column %d: %d
", j + 1, sum);n }n}nvoid calculate_remaining_values(void) {n int row_sums[ROW], col_sums[COL];n for (int i = 0; i < ROW; ++i) {n row_sums[i] = 0;n for (int j = 0; j < COL; ++j) {n row_sums[i] += array[i][j];n }n }nn for (int j = 0; j < COL; ++j) {n col_sums[j] = 0;n for (int i = 0; i < ROW; ++i) {n col_sums[j] += array[i][j];n }n }nn for (int i = 0; i < ROW; ++i) {n for (int j = 0; j < COL; ++j) {n if (array[i][j] == 0) {n int row_sum = row_sums[i];n int col_sum = col_sums[j];n array[i][j] = row_sum - col_sum;n }n }n }n}nvoid find_locations(void) {n for (int i = 0; i < ROW; ++i) {n for (int j = 0; j < COL; ++j) {n if (array[i][j] != 0) {n printf("Value %d is located in row %d column %d
", array[i][j], i + 1, j + 1);n }n }n }n```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Code Interview Questions

#define max 5 #define int arr1[max] main() { typedef char arr2[max]; arr1 list={0,1,2,3,4}; arr2 name="name"; printf("%d %s",list[0],name); }

1 Answers  


main() { int i; printf("%d",scanf("%d",&i)); // value 10 is given as input here }

2 Answers   IBM,


what is the output of following program ? void main() { int i=5; printf("%d %d %d %d %d ",i++,i--,++i,--i,i); }

10 Answers  


main() { unsigned int i=10; while(i-->=0) printf("%u ",i); }

2 Answers   HP,


main() { int i, j, *p; i = 25; j = 100; p = &i; // Address of i is assigned to pointer p printf("%f", i/(*p) ); // i is divided by pointer p } a. Runtime error. b. 1.00000 c. Compile error d. 0.00000

3 Answers   HCL,


#include"math.h" void main() { printf("Hi everybody"); } if <stdio.h> will be included then this program will must compile, but as we know that when we include a header file in "" then any system defined function find its defination from all the directrives. So is this code of segment will compile? If no then why?

2 Answers  


void main() { static int i=5; if(--i){ main(); printf("%d ",i); } }

1 Answers  


main() { int i = 258; int *iPtr = &i; printf("%d %d", *((char*)iPtr), *((char*)iPtr+1) ); }

1 Answers  


main(int argc, char *argv[]) { (main && argc) ? main(argc-1, NULL) : return 0; } a. Runtime error. b. Compile error. Illegal syntax c. Gets into Infinite loop d. None of the above

4 Answers   HCL, LG,


Can you send Code for Run Length Encoding Of BMP Image in C Language in linux(i.e Compression and Decompression) ?

0 Answers   Honeywell,


main() { extern int i; i=20; printf("%d",i); }

1 Answers   Value Labs,


#include<stdio.h> main() { register i=5; char j[]= "hello"; printf("%s %d",j,i); }

2 Answers  


Categories