Thread: Encryption problem!!

  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
    28,413
    Can you do part (i)?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    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
    28,413
    Have you tried casting individual chars to int?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    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,273
    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, 08:21 PM
  2. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06: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, 05:46 PM