Create a free account on Computer Sir Ki Class and unlock access to valuable learning resources.
Exam Paper Downloads: After registering and logging in, you can download exam question papers in PDF format to practice and prepare for your exams.
Student Support: Get assistance with your doubts, queries, and questions related to your studies. Our support is here to help you understand topics and resolve your learning difficulties.
Register today and make your exam preparation easier and more effective!
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
The code has been copied automatically for you in the clipboard. After that open any of the service and press cntrl-v to paste in the given code area. Needs a bit of tweaking as per the link.
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.”