What will be output for the given code?

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

What will be output for the given code?

Post by answerhappygod »

advertisement


var adpushup = window.adpushup || {};
adpushup.que = adpushup.que || [];
adpushup.que.push(function () {
if (adpushup.config.platform === "MOBILE") {
adpushup.triggerAd("90f55663-effd-4105-b1e7-29d86b526544");
} else if ((window.outerWidth <= 768) || (window.outerWidth == 0)) {
adpushup.triggerAd("90f55663-effd-4105-b1e7-29d86b526544");
}
});
#include<bits/stdc++.h>
using namespace std;
string encrypter(string keyword)
{
string encoded = "";
bool arr[26] = {0};
for (int i=0; i<keyword.size(); i++)
{
if(keyword >= 'A' && keyword <= 'Z')
{
if (arr[keyword-65] == 0)
{
encoded += keyword;
arr[keyword-65] = 1;
}
}
else if (keyword >= 'a' && keyword <= 'z')
{
if (arr[keyword-97] == 0)
{
encoded += keyword - 32;
alpha[keyword-97] = 1;
}
}
}
for (int i=0; i<26; i++)
{
if(arr[i] == 0)
{
arr[i]=1;
encoded += char(i + 65);
}
}
return encoded;
}
string ciphertxt(string msg, string encoded)
{
string cipher="";
for (int i=0; i<msg.size(); i++)
{
if (msg[i] >='a' && msg[i] <='z')
{
int pos = msg[i] - 97;
cipher += encoded[pos];
}
else if (msg[i] >='A' && msg[i] <='Z')
{
int pos = msg[i] - 65;
cipher += encoded[pos];
}
else
{
cipher += msg[i];
}
}
return cipher;
}
int main()
{
string keyword;
keyword = "cipher";
string encoded = encrypter(keyword);
string message = "hello";
cout << ciphertxt(message,encoded) << endl;
return 0;
}
a) bejjm
b) LFPDAR
c) BEJJM
d) lfpdar
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!

This topic has 1 reply

You must be a registered member and logged in to view the replies in this topic.


Register Login
 
Post Reply