Thomas_27 0 Newbie Poster

New to asking help but I'm desperate. I have most of the code I just need advice and also how to put the value from the file into the array and then pass to the functions without using any strings or string header. Basically trying to make this work and I'm stuck.

#include <iostream>
#include <iomanip>
#include <fstream>

//Array Size Set
const int ARRAYSIZE = 25;

using namespace std;

//Declaring Function Prototypes
char findComplement(char,char);
char findmRNA(char,char);
bool isPalindrom();
char displayResults(char,char,char);

int main()
{
//Declaring Arrays with constant size of 25
char dnaArray[ARRAYSIZE];
char comArray[ARRAYSIZE];
char rnaArray[ARRAYSIZE];

    int size=0;
    int i=0;
    char aChar;
    char n;
    char base;
    char comp;
    char temp;

//Opening text file that is in the same folder
ifstream inFile;
inFile.open("dna.txt");

//Making sure the file will open and not the end of file
    while(inFile.good)
    {
        inFile.peek()!=EOF)
    inFile.get(dnaArray[i],size,'\n');

        if(!inFile.good)
        {
    cout << "Cannot Compute Error Error" << endl;
    return 0;
        }//ending if statement
    aChar = temp;// trying to put a temp value for the array so I may get more letters one at a time and store them

    char findComplement(char dnaArray, char compArray);
    char findmRNA(char dnaArray, char rnaArray);
    bool isPalindrom(char dnaArray[],char rnaArray[]);
    char displayResults(char dnaArray,char comArray, char rnaArray);

    inFile.close();
    }
    return 0;

}
char findComplement(char dnaArray[],char compArray[],int size);

for(i=0;i<size;i++)

{
//a switch to change the DNA to its complement
    switch(dnaArray[i])
    {
    case 'A':
        compArray[i] = 'T';
        break;
    case 'T':
        compArray[i] = 'A';
        break;
    case 'G':
        compArray[i] = 'C';
        break;
    case 'C':
        compArray[i] = 'G';
        break;
    }
    assert(false);
}
// Function to Find the mRNA
char findmRNA(char dnaArray[],char rnaArray[]int size);

for(i=0;i<=size;i++)
{
    if(compArray[i] = 'T')
    {
    compArray[i] = 'U';
    }
}
//Declaring a bool function to accept true or false
bool isPalindrome(char dnaArray[],char rnaArray[],int size)
{
    for(int i = 0; i<size/2; i++)
    {
        if (dnaArray[i] != compArray[size - 1 - i])
        {
        return false;
        }//ending if statement

    }//ending for loop
    return true;
}//ending bool function

//Creating a function to display the result of the arrays
char displayResults()
{
cout << "DNA:" << endl;
cout << '   ' << dnaArray << endl;
cout << '   ' << compArray << endl;
cout << "mRNA:" << endl;
cout << '   ' << rnaArray << endl;
if(isPalindrome = true)
{
    cout << "The DNA strand is a palindrome." << endl;
}
else
    cout << "The DNA strand is not a palindrome." << endl;
}//ending displayResults function
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.