Write a complete function:
DNA represented as a list of the alphabet letters A, C, G and T.
How many times the sequence ACG occurs in a specific DNA string.
(An example: If the list is CACGTTGCGTACGAA, then the number of occurrences of ACG will be 2.)
Write function nrACGOccur. Do not use any string member functions.
Assume the following:
• a global declaration:
const int numChars = 50; ; // number of characters in the array
• local declarations in the main function
char geneticArray[numChars]; // the array representing DNA
int nrOccur; ; // number of occurrences of ACG
• values have been assigned to all the elements in the array geneticArray
• the function is called in the main function as follows:
nrOccur = nrACGOccur(geneticArray);
Write down ONLY the complete function nrACGOccur.
This is what I did but unable to run the program - This is the 2 warnings I get
error C:\unisa\cos111\oct2007quest4.cpp:9
non-lvalue in increment
error C:\unisa\cos111\oct2007quest4.cpp:11
ISO C++ forbids comparison between pointer and integer
# include <iostream>
using namespace std;
const int NUM_CHARS =50;
char nrACGOccur(char genArray[])
{
int nrOccurP = 0;
for (int i= 0; i < NUM_CHARS; 1++)
{
if (genArray[i] == "ACG")
nrOccurP++;
}
return nrOccurP;
}
int main ( )
{
char geneticArray[] = {"CACTGACGACGCCGTACGCCTTGG"};
int nrOccur;
nrACGOccur(geneticArray);
cout << nrOccur << endl;
return 0;
}