there is a matrix N x N .Its elements consist of either
value =1 or value=0.
If there is a any zero in the row, then the output matrix
should have all zeroes in that row.
If there is a single zero in any column then that column
should have all zeroes n the output matrix.
write the function to perform these operations.

i want a solution in c/c++ language



there is a matrix N x N .Its elements consist of either value =1 or value=0. If there is a any zer..

Answer / Manish Mishra

```cn#include <stdio.h>nnvoid printZeroRows(int matrix[][10], int size)n{n for (int i = 0; i < size; ++i)n {n int zeroCount = 0;n for (int j = 0; j < size; ++j)n {n if (matrix[i][j] == 0) ++zeroCount;n }n if (!zeroCount){n for (int k = 0; k < size; ++k)n matrix[i][k] = 0;n }n }n}nnvoid printZeroColumns(int matrix[][10], int size)n{n for (int i = 0; i < size; ++i)n {n int zeroCount = 0, zeroRow = -1;n for (int j = 0; j < size; ++j)n {n if (matrix[j][i] == 0)n {n if (!zeroCount)n {n zeroCount++;n zeroRow = j;n }n else matrix[zeroRow][j] = 0;n }n }n }n}nnint main()n{n int matrix[][10] = {n {1, 0, 1, 1},n {1, 1, 1, 0},n {1, 1, 1, 1},n {0, 1, 1, 1}n };n int size = sizeof(matrix) / sizeof(matrix[0]);n printZeroRows(matrix, size);n printZeroColumns(matrix, size);n for (int i = 0; i < size; ++i)n {n for (int j = 0; j < size; ++j)n {n printf("%d", matrix[i][j]);n if (j != size - 1) printf(" ");n }n printf("n");n }n return 0;n}n```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More General Aptitude Interview Questions

if 2^51 is 8 then 2^48 is ?

3 Answers  


There is a school with 100 students and correspondingly 100 lockers, all of which start off closed. The first student opens every locker and the second students closes every other locker starting with the second (2,4,6...etc..) . The 3rd student changes the state of the lockers numbered (3,6,9.. etc.). The fourth student changes the state of the lockers numbered (4,8,12.. etc..).. This continues until all the 100 students passes along the lockers.. when all the 100 student is done which locker is closed and which locker is in open condition?

6 Answers   TCS, Zoho,


The minute hand of a clock overtakes the hour hand at intervals of 64 minutes of correct time. How much a day does the clock gain or lose?

1 Answers   iNautix, Wipro,


5 thieves stole diamonds in following way 1st stole half +2 2nd remaining half +2. for 5th there was no diamond how many diamond were there initially

1 Answers   Infosys,


A is twice efficient than B. A and B can both work together to complete a work in 7 days. Then find in how many days A alone can complete the work?

1 Answers   Accenture, BSNL,


where is the central rice research institute located

4 Answers   CDS,


Dear aspirants.. dont apply for bank jobs wildly without Knowing why how.. bcoz sbi.. do u know, how many of ur Friends selected? Its a big fraud.. this is shit. Thers a Backdoor system to get job in sbi. u cant get selected even U have talent, or merit. People even cant do simple Reasoning questions, are now selected for clerk job. they Told personally that bcoz of influence i got that. Sbi Collecting funds under this bloody recruitment. Do u know? For 1 person 250/-. in that manner nearly sbi collected Funds from 8 lakh people. If u ignore sc st candidates, Nearly from 6.5 lakh people it collected. That means 650000*250=162500000. its not doing at a time. U people Dont fell in this trap. U wont get job, but ur pocket may Get hole if u mess with sbi.. beware people..

3 Answers  


Find sqrt of 113 up to 3 decimal places.

1 Answers   Bently,


If a bat costs Rs.30 in the year 1999 and Rs.250 in the year 2000.What is the percent increase in price?

1 Answers   3i Infotech,


A man how many bikes of Rs 14000 can buy by selling 2100 bikes of Rs500/- of each

1 Answers   Ramco,


A beats B by 10 meters and B beats C by 15 metres the A beats C by

1 Answers   Accenture,


2 hours after a freight train leaves Delhi a passenger train leaves the same station travelling in the same direction at an average speed of 16 km/hr. After travelling 4 hrs the passenger train overtakes the freight train. The average speed of the freight train was?

1 Answers  


Categories