#include <stdio.h>
#include <string.h>
int calculateHammingDistance(const char *strand1, const char *strand2) {
int i, distance = 0;
// Ensure the strands are of the same length
if (strlen(strand1) != strlen(strand2)) {
printf("Error: DNA strands must be of the same length.\n");
return -1;
}
// Calculate the Hamming distance
for (i = 0; strand1[i] != '\0'; i++) {
if (strand1[i] != strand2[i]) {
distance++;
}
}
return distance;
}
int main() {
char strand1[100], strand2[100];
int hammingDistance;
// Input two DNA strands
printf("Enter the first DNA strand: ");
scanf("%s", strand1);
printf("Enter the second DNA strand: ");
scanf("%s", strand2);
// Calculate the Hamming distance
hammingDistance = calculateHammingDistance(strand1, strand2);
// Output the result if no error
if (hammingDistance != -1) {
printf("Hamming Distance: %d\n", hammingDistance);
}
return 0;
}