Encryption problem!!

This is a discussion on Encryption problem!! within the C++ Programming forums, part of the General Programming Boards category; hey guys, im a newbie who has just started programmin. i recieved a homework question which has something to do ...

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    33

    Encryption problem!!

    hey guys, im a newbie who has just started programmin. i recieved a homework question which has something to do with this..
    "The program has to ask a user to enter their name, and the output will be :

    User entered david.. the output will be:
    i) The ascii value for D is 68, a 97, v 118, i 105, d 100
    ii)68 in binary is 10001000
    97 in binary is 1100001
    etc....
    iii) the number of ones in the binary code for david is 2,3 etc.. and this number can be joined as 23etc....
    iv)reading this number right to left gives us etc32...which can be converted to binary.
    v)then this number in decimal would be.....
    vi)then adding the decimal numbers together will give us a number.. then adding both numbers in that number together will give us the answer.


    thats it for now.. if any1 can help me thru this or if i cud get sum ideas on where to start.. nething would be appreciated..

    thanks in advanced

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,589
    Can you do part (i)?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Aug 2006
    Posts
    33
    umm not really.. dont really kno where to start.. i guess i could look it up in google but i want to understand it. know what i mean

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,589
    Have you tried casting individual chars to int?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    I,
    Code:
    string Name = "";
    
    cout<< "Enter your name - ";
    cin >> Name;
    
    for ( int i=0; i<(int)Name.size(); i++ )
    {
    	cout<< '\n' << (int)Name[i];
    }
    for most of the rest, look into <bitset>

  6. #6
    Registered User
    Join Date
    May 2006
    Posts
    903
    Show some code, we'll talk later.

  7. #7
    Moderately Rabid Decrypt's Avatar
    Join Date
    Feb 2005
    Location
    Milwaukee, WI, USA
    Posts
    300
    I don't see how you need our help, your post is already encrapped as it is.

    Read me.
    There is a difference between tedious and difficult.

  8. #8
    Registered User
    Join Date
    Aug 2006
    Posts
    33
    ok guys i will post some code for help.. thanks in advanced

  9. #9
    Registered User
    Join Date
    Aug 2006
    Posts
    33
    basically this is what i have and i need a user to enter there name and the binary value will come out for that asci value.. i did both codes separatelly but cant combine.. any help ?

    Code:
    #include <cstdlib>
    #include <iostream>
    
    using namespace std;
    void binary(int);
    
    int main()
    {
        string name = "";
    
        cout<< "Please enter your name: ";
        cin >> name;
    
        for ( int i=0; i<(int)Name.size(); i++ )
    {
    	cout<< '\n' << (int)name[i] <<" ";
    }
        cout<<endl;
        system("PAUSE");
        return EXIT_SUCCESS;
    }
    
    
    
    void binary(int number) {
    	int remainder;
    
    	if(number <= 1) {
    		cout << number;
    		return;
    	}
    
    	remainder = number%2;
    	binary(number >> 1);    
    	cout << remainder;

  10. #10
    Registered User
    Join Date
    Aug 2006
    Posts
    33
    problem fixed!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help needed with edit control & encryption
    By willc0de4food in forum Windows Programming
    Replies: 2
    Last Post: 03-16-2006, 07:21 PM
  2. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 05:24 PM
  3. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM
  4. binary tree problem - help needed
    By sanju in forum C Programming
    Replies: 4
    Last Post: 10-16-2002, 05:18 AM
  5. beginner problem
    By The_Nymph in forum C Programming
    Replies: 4
    Last Post: 03-05-2002, 04:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21