First Program Help

This is a discussion on First Program Help within the C++ Programming forums, part of the General Programming Boards category; This is my first attempt at C++ programming, only done a bit in Small. I want to create a program ...

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    2

    First Program Help

    This is my first attempt at C++ programming, only done a bit in Small. I want to create a program that finds the pair for a DNA sequence on the molecule. So if the Input string is CTTAG, all C's would be replacesd with T's, all G's with A's and vice versa. The output woud be TCCGA. So basically it reads the string, replaces the letters, and prints it back, for any length string.
    Any help, or pointers in the right direction? I am really quite a newbie. Thanks

  2. #2
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696
    Just start coding. You got the algorithm down already. Post code when you have any problem.
    I hope "This is my first attempt at C++" does not mean that this is your first program. If so, start reading tutorial on this site.
    Welcome and good luck!
    source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

  3. #3
    Registered User
    Join Date
    May 2004
    Posts
    6
    If you wanted to get advanced, you could use string.h functions, but a more novice way would be to input a string using getline() and pick out specific characters with a for loop and if statements.

  4. #4
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    like alphaoide said, just jump in. make a mess of your code and when you get confused come back with what you have. a suggestion I have is to use C-style strings and use the strlen() function found in <cstring>. ignore what UnderGod said... the way I would do it is to do this:

    1) take in teh string (getline())
    2) loop through the string, character by character (strlen(),for(),char arrays)
    3) use if statements to compare each character
    4) replace the character if necessary
    5) output the string again
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  5. #5
    Registered User
    Join Date
    May 2004
    Posts
    2
    Ok, Ill try that but it nearly is my first attempt at coding, the things I made were quite pitiful. Anyway I'll try.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 12:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 12:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 09:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

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