SAP Labs Coding Interview Question 1
[wpdm_package id=’1421′]
Question – Reverse a string
Conditions – i. I have to reverse word by word.
ii. When I reverse a word the Last alphabet of word should be printed as capital letter.
Input – Amrita is good platform for research
output – AtirmA Si Doog Mroftalp Rof Hcraeser
[sourcecode lang=”cpp”]
while(i<size){
if(s[i]!=’ ‘&& s[i]!=’,’ && s[i]!=’.’ && s[i+1]!=’\0’){
i++;n=i;
}
else{
int f=0;
for(int end=n;end>=p;end–){
if(f==0 && (s[end]>=97 && s[end]<=123)){
putchar(toupper(s[end]));
f=1;
}
else
cout<<s[end];
}
p=i;
n=++i;
}
}
[/sourcecode]
hey,
was there any specification during aptitude test whether to use c , c++ or java while writing the code…??
As i more friendly with java!!!
Hi Subham,
There was no specification. You can use any language to write code. It’s an online editor.
How to implement this problem there is no starting code.
Please check now.
i want to know is there any limit that we can try compiling and execute number of times or can we try executing our code any number of times??
Hi Karan,
There was no limit. You can compile and execute your code any number of times.
Can we use python to write our code ?
yes, you can use Python.