C++

2020-02-29 20:23:50


 Anwar Husseny Labaran
Anwar Husseny Labaran

How can i write a c++ program that eneript 3 letter world 

 Mohammad
Jafar Mohammad

doe's mean 3 letter world or 3 letter word, pleaese retype the complete question  clearly again?


2020-03-01 02:14:37

 Labaran
Anwar Husseny Labaran

Write a C++ program that Encrypt Three letter word 


2020-03-01 02:57:28

 Mohammad
Jafar Mohammad

very simple just follow the bellow links I suggested if you don't like the decryption function remove it and leave the encryption function only

http://www.cplusplus.com/forum/beginner/1665/

https://www.geeksforgeeks.org/program-to-encrypt-a-string-using-and/

 


2020-03-01 04:30:12

 Mohammad
Jafar Mohammad

please call my number


2020-03-01 04:32:48

 Mohammad
Jafar Mohammad

Examples:

Input: string = "Ab" 
Output: !@@
Explanation:
Position of 'A' in alphabetical order is 1
and in String is odd position 
so encrypted message will have 1 '!'

Position of 'b' in alphabetical order is 2
and in String is even position 
so encrypted message will have 2 '@'

Therefore, the output "!@@"

Input: string = "CDE"
Output: !!!@@@@!!!!!


// C program to Encrypt the String

// using ! and @

  

#include <stdio.h>

#include <string.h>

  

// Function to encrypt the string

void encrypt(char input[100])

{

  

    // evenPos is for storing encrypting

    // char at evenPosition

    // oddPos is for storing encrypting

    // char at oddPosition

    char evenPos = '@', oddPos = '!';

  

    int repeat, ascii;

  

    for (int i = 0; i <= strlen(input); i++) {

  

        // Get the number of times the character

        // is to be repeated

        ascii = input[i];

        repeat = ascii >= 97 ? ascii - 96 : ascii - 64;

  

        for (int j = 0; j < repeat; j++) {

            // if i is odd, print '!'

            // else print '@'

            if (i % 2 == 0)

                printf("%c", oddPos);

            else

                printf("%c", evenPos);

        }

    }

}

  

// Driver code

void main()

{

    char input[100] = { 'A', 'b', 'C', 'd' };

  

    // Encrypt the String

    encrypt(input);

}

 

Output:

!@@!!!@@@@

2020-03-01 04:45:57

 Labaran
Anwar Husseny Labaran

Sir I have run the program and it give me some errors that I can't correct it how can I do now 


2020-03-03 07:27:03

 Labaran
Anwar Husseny Labaran

Sir I have run the program but it gives me some errors but I try to correct it, but I can't do it , how will I correct it 


2020-03-03 07:30:36

 Labaran
Anwar Husseny Labaran


2020-03-03 07:32:23

You need to Log In or Register to post comments.