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]

8 Replies to “SAP Labs Coding Interview Question 1”

  1. 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!!!

  2. 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??

Leave a Reply

Your email address will not be published. Required fields are marked *