Given a string, shift the alphabets of the string to plus "K"th position.
For Example: If the given string is "abcdefg" and the shift K= 3
Then the output is "defghij"
Implementation:
For Example: If the given string is "abcdefg" and the shift K= 3
Then the output is "defghij"
Implementation:
#include <iostream> using namespace std; int main() { int N,K; cin>>N; char ch[N]; cin>>ch; cin>>K; for(int i=0;i<N;i++) { if((ch[i]>='a' && ch[i]<='z') || (ch[i]>='A' && ch[i]<='Z')) { if(ch[i]+K<='z') cout<<char(ch[i]+K); else cout<<char(ch[i]-26+K); } else cout<<ch[i]; } return 0; }