. Write a program using two-dimensional arrays that computes
the sum of data in tows and the sum of data in columns of
the 3x3 (three by three) array variable n[3][3].

Answers were Sorted based on User's Feedback



. Write a program using two-dimensional arrays that computes the sum of data in tows and the sum of..

Answer / sreejesh1987

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,a[3][3],rowsum[3],colsum[3];
clrscr();

for(i=0;i<3;i++)
rowsum[i]=colsum[i]=0;

printf("Enter numbers:\n");
for(i=0;i<3;i++)
for(j=0;j<3;j++)
{
scanf("%d",&a[i][j]);
rowsum[i]+=a[i][j];
colsum[j]+=a[i][j];
}


for(i=0;i<3;i++)
printf("RowSum[%d]:%d\n",i,rowsum[i]);

for(i=0;i<3;i++)
printf("Columnsum[%d]:%d\n",i,colsum[i]);

getch();
}

Is This Answer Correct ?    28 Yes 17 No

. Write a program using two-dimensional arrays that computes the sum of data in tows and the sum of..

Answer / rowel baldemoro

#include<stdio.h>
#include <conio.h>
#include <windows.h>
#include <iostream>

using namespace std;
void design(int x, int y){

COORD coord;
coord.X=x;
coord.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);


}
int main()
{

int no[3][3],sum[2][3];

//1x3
design(1,0);
cin>>no[0][0];

design(4,0);
cin>>no[0][1];

design(7,0);
cin>>no[0][2];
sum[0][0]=no[0][0]+no[0][1]+no[0][2];

design(8,0);
printf("=%d",sum[0][0]);
//2x3
design(1,2);
cin>>no[1][0];

design(4,2);
cin>>no[1][1];

design(7,2);
cin>>no[1][2];
sum[0][1]=no[1][0]+no[1][1]+no[1][2];

design(8,2);
printf("=%d",sum[0][1]);
//3x3
design(1,4);
cin>>no[2][0];

design(4,4);
cin>>no[2][1];

design(7,4);
cin>>no[2][2];
sum[0][2]=no[2][0]+no[2][1]+no[2][2];

design(8,4);
printf("=%d",sum[0][2]);

sum[1][0]=0;
for(int i=0;i<3;i++){
design(1,6);

sum[1][0]=sum[1][0]+no[i][0];
cout<<sum[1][0];
}
design(4,6);


design(7,6);

getch();
}

Is This Answer Correct ?    10 Yes 4 No

Post New Answer

More C++ Code Interview Questions

Wrie a function which returns the most frequent number in a list of integers. Handle the case of more than one number which meets this criterion. public static int[] GetFrequency(int[] list)

3 Answers   Nagarro,


how to take time as input in the format (12:02:13) from user so that controls remains between these columns?

0 Answers  


Where now stands that small knot of villages known as the Endians, a mighty forest once stood. Indeed, legand has it that you could have stoodon the edge of the wood and seen it stretch out for miles, were it not for the trees getting in the way. In one section of the forest, the trees stood in a row and were of hight from 1 to n, each hight occurring once and once only. A tree was only visible if there were no higher trees before it in the row. For example, if the heights were 324165, the only visible trees would have been those of height 3,4 & 6. Write a Program that takes an array of integers representing the heights of the trees in the row as input and prints the list of the visible trees.

2 Answers   ABC, Nagarro,


write a program to sort 'n' elemnts using bubble sort

1 Answers   IBM,


Question 1: Implement a base class Appointment and derived classes Onetime, Daily, Weekly, and Monthly. An appointment has a description (for example, “see the dentist”) and a date and time. Write a virtual function occurs_on(int year, int month, int day) that checks whether the appointment occurs on that date. For example, for a monthly appointment, you must check whether the day of the month matches. Then fill a vector of Appointment* with a mixture of appointments. Have the user enter a date and print out all appointments that happen on that date. *This Should Be Done IN C++

0 Answers  






Write a program to enter 10 number of integer entries into an array n and then odds up all the odd entries. the program then displays the result. plssss answer assss fast asss u can...

1 Answers  


Here's the programm code: int magic(int a, int b) { return b == 0 ? a : magic(b, a % b); } int main() { int a, b; scanf("%d%d", &a, &b); printf("%d\n", magic(a, b)); return 0; } on input stream we have integers 4, 45 What's the output integer? How many times will be initiated "magic" function?

1 Answers  


Create a program to read two random data set in two files named data1.txt and data2.txt manifold contains integer numbers, whereas data2.txt file contains the float type numbers. Simpanlahmasing each into 2 pieces of data that is an array of type integer array and an array of type float, then calculate the average numbers in the second array.

0 Answers  


What is the time complexity T(n) of the following program? a) int n, d, i, j; cin >> n; for (d=1; d<=n; d++) for (i=1; i<=d; i++) for (j=1; j<=n; j += n/10) cout << d << " " << i << " " << j << endl; b) void main() { int n, s, t; cin >> n; for (s = 1; s <= n/4; s++) {t = s; while (t >= 1) { cout << s << " " << t << endl; t--; } } } c) void main() { int n, r, s, t; cin >> n; for (r = 2; r <= n; r = r * 2) for (s = 1; s <= n/4; s++) { t = s; while (t >= 1) { cout << s << " " << t << endl; t--; } } }

3 Answers   CTS, IBM, Infosys, Qatar University,


Subsets Write an algorithm that prints out all the subsets of 3 elements of a set of n elements. The elements of the set are stored in a list that is the input to the algorithm. (Since it is a set, you may assume all elements in the list are distinct.)

1 Answers   CSC, Qatar University,


Write a program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors.

5 Answers   ADP, Amazon, HCL, IBM, Infosys, Satyam, TCS, Vimukti Technologies,


i really need help about this.. write a program to display the set of odd and even numbers separately. find the highest and lowest value of the given numbers.

0 Answers  


Categories