SAP Labs Coding Interview Question 1


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 comments on “SAP Labs Coding Interview Question 1

  1. shubham

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

    Reply
    1. robin Post author

      Hi Subham,

      There was no specification. You can use any language to write code. It’s an online editor.

      Reply
  2. karan

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

    Reply

Leave a Reply

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