3) Int Matrix of certain size was given, We had few valu=
es in it like this.

=97=97=97=97=97=97=97=97=97=97=97
1 = | 4 | | 5 | &= nbsp; | 45
=97=97=97=97=97=97=97=97=97=97=97
&n= bsp; | 3 | 3 | 5 | = | 4
=97=97=97=97=97=97=97=97=97=97=97
34 |&nbs= p; 3 | 3 | | 12 | &= nbsp;
=97=97=97=97=97=97=97=97=97=97=97
3 | &nbs= p; | 3 | 4 | = | 3
=97=97=97=97=97=97=97=97=97=97=97
3 | = ; | | | = ; 3 |
=97=97=97=97=97=97=97=97=97=97=97
&= nbsp; | | 4 | = ; | 4 | 3

We w= ere supposed to move back all the spaces in it at the
end.

Note: = If implemented this prog using recursion, would get
higher preference.



3) Int Matrix of certain size was given, We had few valu= es in it like this. =97=97=97=97=97=9..

Answer / Ajay Vikram

To solve this problem recursively, we can create a function that takes a matrix and a row number as input. If the row number is greater than the size of the matrix, return. Otherwise, for each space in the row, if the cell value is not a space character (' '), append it to the result string. Then, call the function recursively for the next row, incrementing the row number by 1. When we reach the last row, reverse the resulting string to move the spaces back to their original positions.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Code Interview Questions

Is the following code legal? void main() { typedef struct a aType; aType someVariable; struct a { int x; aType *b; }; }

1 Answers  


Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it.

2 Answers   Wipro,


how many processes will gate created execution of -------- fork(); fork(); fork(); -------- Please Explain... Thanks in advance..!

8 Answers   GATE,


why the range of an unsigned integer is double almost than the signed integer.

1 Answers  


Write a C program to print ‘Campus Force training’ without using even a single semicolon in the program.

3 Answers   Wipro,


why is printf("%d %d %d",i++,--i,i--);

4 Answers   Apple, Cynity, TCS,


1) int i=5; j=i++ + i++ + i++; printf("%d",j);This code gives the answer 15.But if we replace the value of the j then anser is different?why? 2)int i=5; printf("%d",i++ + i++ + i++); this givs 18.

8 Answers   IBPS, Infosys, TCS,


main() { unsigned int i=65000; while(i++!=0); printf("%d",i); }

1 Answers  


Who could write how to find a prime number in dynamic array?

1 Answers  


write a c program to Reverse a given string using string function and also without string function

1 Answers  


main() { printf("%d", out); } int out=100;

3 Answers  


main( ) { char *q; int j; for (j=0; j<3; j++) scanf(“%s” ,(q+j)); for (j=0; j<3; j++) printf(“%c” ,*(q+j)); for (j=0; j<3; j++) printf(“%s” ,(q+j)); }

1 Answers  


Categories