Secret code with alphabet divisible by five – CSKC
Sign In

Search

Solved Problem #CPP#2047    siteicon   siteicon  

Problem Statement - Secret code with alphabet divisible by five

Instead of sending his secret code a programmer tells his friend that my secret code is a series of characters which are upper and lower alphabet sequence in their ascending order which are divisible by five. Can you help the programmer’s friend to decipher this code.

Solution

TC++ #2047

 

×

Ask AI About This Code

Default Prompt that is passed along with the code is given below, You can write your own prompt if you so desire.



×

Test CPP

for(int i=65;i<=90;i++)
This one takes care of upper case range of alphabets from 65 to 90

if(i%5==0) cout<<(char)i<<” “;
Here we check divisibility by 5 using i%5==0. If divisible we print the equivalent alphabet by (char) typecasting of equivalent integer ascii code.

for(int i=97;i<=122;i++)
This one is for lower case alphabet range from 97 to 122.

if(i%5==0) cout<<(char)i<<” “;
Here again divisibility by 5 is tested and then character version is printed.

Finally we get the code as
A F K P U Z d i n s x

Notes

  • These are innovative ways of narrating simple programming assignments. students are advised to carefully mark each of the relevant words in the question like follows -“Instead of sending his secret code a programmer tells his friend that my secret code is a series of characters which are upper and lower alphabet sequence in their ascending order which are divisible by five. Can you help the programmer’s friend to decipher this code.”


Share

Created: 30-Dec-2017 23:51 | Updated: 13-Dec-2018 23:57|