## Dynamic Programming

This yields the following algorithm

 ```1 2 3 4 5 6 7 8 9 ``` `int LPS(char* str, int a, int b) {` `  if (a > b)` `     return 0;` ``` ``` `  if (a == b)` `     return 1;` ``` ``` `   if (str[a] == str[b])` `     return LPS(str, a+1, b-1) + 2 ;` ``` ``` `   return max(LPS(str, a+1, b), LPS(str, a, b-1));` `}`

// Returns the length of the longest palindromic subsequence in seq

`int` `lps(``char` `*seq, ``int` `i, ``int` `j)`
`{`
`   ``// Base Case 1: If there is only 1 character`
`   ``if` `(i == j)`
`     ``return` `1;`
`   ``// Base Case 2: If there are only 2 characters and both are same`
`   ``if` `(seq[i] == seq[j] && i + 1 == j)`
`     ``return` `2;`
`   ``// If the first and last characters match`
`   ``if` `(seq[i] == seq[j])`
`      ``return` `lps (seq, i+1, j-1) + 2;`
`   ``// If the first and last characters do not match`
`   ``return` `max( lps(seq, i, j-1), lps(seq, i+1, j) );`
`}`
 `/* Driver program to test above functions */` `int` `main()` `{` `    ``char` `seq[] = ``"GEEKS FOR GEEKS"``;` `    ``int` `n = ``strlen``(seq);` `    ``printf` `(``"The length of the LPS is %d"``, lps(seq));` `    ``getchar``();` `    ``return` `0;` `}`
Output:
`The length of the LPS is 7`

### C Questions

C Questions
C Questions

Note : All the programs are tested under Turbo C/C++ compilers.
It is assumed that,
Programs run under DOS environment, The underlying machine is an x86 system, Program is compiled using Turbo C/C++ compiler.
The program output may depend on the information based on this assumptions (for example sizeof(int) == 2 may be assumed).
Predict the output or error(s) for the following:

void main()
{
int const * p=5; printf("%d",++(*p));
}
Compiler error: Cannot modify a constant value.
Explanation:
p is a pointer to a "constant integer". But we tried to change the value of the "constant integer".
main()
{
char s[ ]="man"; int i;
for(i=0;s[ i ];i++)
printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
}
aaaa nnnn
Explanation

### Zoho Interview | Set 1 (Advanced Programming Round)

Third Round: (Advanced Programming Round) Here they asked us to create a “Railway reservation system” and gave us 4 modules. The modules were:
1. Booking
2. Availability checking
3. Cancellation
4. Prepare chart
We were asked to create the modules for representing each data first and to continue with the implementation phase.

My Solution :