## Basic Concepts of Questions on Boats and Streams

1. A boat is said to go downstream, if the boat goes in the direction of stream.
2. A boat is said to go upstream, if the boat goes opposite to the direction of stream.

## Basic Formulas

1. If speed of boat in still water is b km/hr and speed of stream is s km/hr,
• Speed of boat in downstream = (b  + s) km/hr , since the boat goes with the stream of water.
• Speed of boat in upstream = (b  - s) km/hr. The boat goes against the stream of water and hence its speed gets reduced.

## Shortcuts With Explanation

Scenario 1: Given a boat travels downstream with speed d km/hr and it travels with speed u km/hr upstream. Find the speed of stream and speed of boat in still water.
Let speed of boat in still water be bkm/hr and speed of stream be skm/hr.
Then b + s  = d and b – s = u.
Solving the 2 equations we get,
b = (d + u)/2
s = (d – u)/2

Scenario 2: A man can row a boat, certain distance downstream in td hours and returns the same distance upstream in tu hours. If the speed of stream is s km/h, then the speed of boat in still water is given by
We know distance = speed * time
Let the speed of boat be b km/hr
Case downstream:
d = (b + s) * td
Case upstream:
d = (b - s) * tu

=>    (b + s) / (b - s) = tu / td

b = [(tu + td) / (tu - td)] * s

Scenario 3: A man can row in still water at b km/h. In a stream flowing at  s km/h, if it takes him t hours to row to a place and come back, then the distance between two places, d is given by
Downstream:  Let the time taken to go downstream be td
d = (b + s) * td

Upstream: Let the time taken to go upstream be tu
d = (b - s) * tu

td + tu = t
[d / (b + s)] + [d / (b - s)] = t
So, d = t * [(b2 - s2) / 2b]
OR
d = [t * (Speed to go downstream) * (Speed to go upstream)]/[2 * Speed of boat or man in still water]

Scenario 4: A man can row in still water at b km/h. In a stream flowing at s km/h, if it takes t hours more in upstream than to go downstream for the same distance, then the distance d is given by
Time taken to go upstream = t + Time taken to go downstream
(d / (b - s)) = t + (d / (b + s))
=> d [ 2s / (b2 - s2 ] = t
So, d = t * [(b2 - s2) / 2s]
OR
d = [t * (Speed to go downstream) * (Speed to go upstream)] / [2 * Speed of still water]

### 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 :