Thread: Help please

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    4

    Help please

    Hi, have the below mention design, anyone know how to write the program or can direct me to any help? Any help will be greatly appreciated, thanks. Take for example an input string "This is *swaped* here no change" will produce an output string " This is *depaws* here no change".

    initialise variables to be used
    read in string to be tested
    loop while end of the string is reached
    if swap is off then
    copy characters from input string to output string
    if end
    if asterisk is found then
    determine the start and stop position of swap
    set swap on
    if end
    if swap is on then
    execute the swap
    set swap off if swap completed
    if end
    loopend
    write out the input string
    write out the output string

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Step 1 - write a program which reads input, and prints the input back to the user unchanged.
    Step 2 - add code to print a message whenever a '*' is seen
    Step 3 - print the number of characters counted between two adjacent '*'

    That should get you going.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Mar 2005
    Posts
    4
    But i dont know how to write the program and I never learn this before, this is actually an assignment from my teacher.

  4. #4
    Registered User
    Join Date
    Mar 2005
    Posts
    6
    Start reading tutorials. If you have never done this before tell that to you teacher.

  5. #5
    email for MystWind avatar MystWind's Avatar
    Join Date
    Feb 2005
    Location
    Holland , The Hague
    Posts
    88
    what do you want us to say ? do you want us to write your whole program or so ?
    this website has a great turtourial , if you would read that , I'm sure half of your questions will be awnserd .

    p.s.define your questions more presice please , I barely know what you Xpect us to do.
    PLay MystWind beta , within two years

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > But i dont know how to write the program
    Have you ever written a C program before?

    Surely your teacher has gone over input and output, even if it's using gets(). At least show what you know along those guidelines I posted so we can best help you with the bit you're actually stuck on.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Registered User
    Join Date
    Mar 2005
    Posts
    4
    I dont know how to write the program at all.

  8. #8
    Registered User
    Join Date
    Sep 2004
    Posts
    197
    The board rules/guidlines state we aren't going to do the work for you. If you don't know how to do the assingment, I would suggest talking to your teacher, because if your in a programming class and aren't learning HOW, to program, I think their might be a problem.
    If any part of my post is incorrect, please correct me.

    This post is not guarantied to be correct, and is not to be taken as a matter of fact, but of opinion or a guess, unless otherwise noted.

  9. #9
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > I dont know how to write the program at all.

    But you've done the printf("hello world\n"); program right?

    And perhaps extended it to printf("hello %s\n", name );
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  10. #10
    Registered User
    Join Date
    Dec 2004
    Posts
    465
    People in C++ classes do printf stuff? Am I missing something?
    My computer is awesome.

  11. #11
    Registered User
    Join Date
    Sep 2004
    Posts
    197
    Quote Originally Posted by cerin
    People in C++ classes do printf stuff? Am I missing something?
    Ill covert it to C++ to see if he has used it then
    something like
    Code:
    cout << "Hello World\n";
    cout << "Hello World" << endl;
    std::cout << "Hello World" << std::endl;
    std::cout << "Hello" << " World" << std::endl;
    any of those can do Hello World, so I want to cover all the bases. Their are more, but those are basic ones I would say.
    If any part of my post is incorrect, please correct me.

    This post is not guarantied to be correct, and is not to be taken as a matter of fact, but of opinion or a guess, unless otherwise noted.

Popular pages Recent additions subscribe to a feed