help: string and random number generator Questions
Expand Post »
So I developed this code so that I would have a program that can randomly generate a DNA sequence.
These are my questions:
1) how can i get the random number sequence to develop in a string?
2) how can i then multiplate the string so that the "A"s are replaced by "G"s or what not?
3) In the RNA portion of it: is there another way to program the yes or no answer responses instead of using if statements?
Also if there is anyother comment on my code its appreciated
cout << sequence << endl; // this should probably be out of the loop though
}
2) Loop through the string, and if it has a 'A', just replace it with a 'G'.
3) with 2 options, an if statement should be fine. You could also use a switch.
BTW, with the line if(answer = Y), you should be using if(answer == 'Y'), so that you compare (rather than assign) to the value of the character Y (rather than the non-existant variable named Y). You should also consider comparing to lowercase 'y'.
Re: help: string and random number generator Questions
It seems to me you're going about this programming stuff the hard way. Based on the code you posted, you have never compiled the program. You really should be writing it a piece at a time, testing that piece, and move on when it's working. You're going to spend a lot more time trying to get it working if you try writing it all first before compiling.
And call srand() only once at the start of the program. You don't need to call it more than once.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.