Click here to Skip to main content
15,889,853 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Note: Assume all required header files are already included in the program.

C++
typedef	char TEXT[80];

void JumbleUp(TEXT T)
{
    int L=strlen(T);
    for (int C=0; C<L-1; C+=2)
    {
        char CT=T[C];

        T[C]=T[C+1];
        T[C+1]=CT;
    }

    for (C=1; C<L; C+=2)
        if (T[C]>=’M’ && T[C]<=’U’)
            T[C]=’@’;
}

void main()
{
    TEXT Str="HARMONIOUS";
    JumbleUp(Str);

    cout<<Str<<end1;
}


What I have tried:

I solved the program but the second loop i cannot understand. The answer is -AHM@N@OIS@


Plz mail me on - [EMAIL REMOVED] with the explanation of the second loop.

Thanks in advance
Posted
Updated 21-Mar-17 9:07am
v4
Comments
[no name] 21-Mar-17 13:51pm    
You would see the explanation yourself if you learned how to use the debugger.
Richard MacCutchan 21-Mar-17 16:25pm    
It's fairly clear: for every odd numbered character replace all letters between 'M' and 'U' with '@'.
Member 13074746 22-Mar-17 7:29am    
Thank you

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!

Try using the debugger and see if you can follow what is going on...
 
Share this answer
 
Comments
Member 13074746 21-Mar-17 16:16pm    
Well first thing is its not my homework. I was just sitting at home feeling boared so i started to search for questions and from those i didnot understand this.
CHill60 21-Mar-17 18:40pm    
If it's not your homework then it's best to avoid "homework season" when you are self-learning. You can tell it's homework season by the number of C or C++ questions in QA worded similarly to yours.
Quote:
I solved the program but the second loop i cannot understand. The answer is -AHM@N@OIS@

The debugger will help you ti understand the code.
When you don't understand what your code is doing or why it does what it does, the answer is debugger.
Use the debugger to see what your code is doing. Just set a breakpoint and see your code performing, the debugger allow you to execute lines 1 by 1 and to inspect variables as it execute, it is an incredible learning tool.

Debugger - Wikipedia, the free encyclopedia[^]
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]
Basic Debugging with Visual Studio 2010 - YouTube[^]

The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't find bugs, it just help you to. When the code don't do what is expected, you are close to a bug.

Quote:
Write the output of the following C++ program?

We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.

As programmer, your job is to create algorithms that solve specific problems and you can't rely on someone else to eternally do it for you, so there is a time where you will have to learn how to. And the sooner, the better.
When you just ask for the solution, it is like trying to learn to drive a car by having someone else training.
Creating an algorithm is basically finding the maths and make necessary adaptation to fit your actual problem.
 
Share this answer
 
Comments
Member 13074746 21-Mar-17 16:18pm    
Well I figured it out so no thanks. And its not my homework
[no name] 22-Mar-17 14:00pm    
Some people have a very odd definition of "homeowrk". Is this a problem that you decided that you wanted to solve yourself? Then it IS homework. It's homework assigned by you to yourself. And you should give yourself a failing grade because you didn't solve it.
Member 13074746 22-Mar-17 14:04pm    
Let me tell u one thing i tried and solve it except for the second loop part.i know u guys are developers and i am just a begineer trying to solve something and u should help me and another after asking i solved it myself without anobodys help just it took some time and also i was trying to check whether my logic of the 2 nd loop is correct or not.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900