I want to create a program which will read a string sequence say AATC upto four characters and calculate the total sum of the values held by each characters. For example if the sequence starts with A the value of A will be 2 if the first letter is G then the value of G is 4 like this. The program will check the string see the first letter and calculate the value until it reaches the end of the string which is the fourth letter and calculate the overall sum. Here is my code.
I am not getting an error but then again I am not getting my result. Please tell me What is the problem in my algorithm or Program.
#include <stdio.h> #include <conio.h> void main(void) { char name[4]; int i,l,s; printf("Enter Seq"); scanf("%c",name[i]); clrscr(); for(i=0; i<4 ;i++) { {if(name[1]=='a') l=2; {if(name[1]=='t') l=-2; {if(name[1]=='g') l=5; {if(name[1]=='c') l=-1; } s=l; } printf("Score is %d",s); getch(); }
I am not getting an error but then again I am not getting my result. Please tell me What is the problem in my algorithm or Program.