Learning Objective Use loops in C to make models of the real

Learning Objective: Use loops in C to make models of the real world. In living organisms, cells continually synthesize hundreds of thousands of different proteins that each carry out a specific function. The procedure for this synthesis is based on genetic information and is carried to the cells by strings of messenger RNA. As a bio-engineer, you have recently isolated a new string of messenger RNA and want to visualize its structure for a presentation to your supervisor. To proof your conceptual idea, you develop a program that will prompt the user for a string of up to 8 characters long. The string can contain the characters \'G\', \'U\', \'A\', or \'C\' in any combination, where each character represents a basis (guanine, uracil, adenine, and cytosine) and will be visualized as follows: The program will output the representation for each basis in the order specified by the user on the same three terminal lines from left to right, with a column of spaces in between each basis. After outputting a representation, the user should be able to enter another RNA sequence to be visualized or enter a single \'X\' to exit the program. It is safe to assume that, for this proof of concept, all characters entered are valid and always upper-case. Example: Enter an RNA sequence or \'X\' to exit: GCA Enter an RNA sequence or \'X\' to exit: X Program Terminated.

Solution

#include<stdio.h>
#include<string.h>
int main()
{
   char text[8];
   int i,j,k,l,res;
   char text2[8];
   strcpy(text2,\"X\");
   do
   {
       printf(\"enter an RNA sequence or X :\");
       scanf(\"%s\",text);
       for(i=0;text[i];i++)
       {
       if(text[i]==\'G\')
       {
           for(j=0;j<3;j++)
           {
               for(k=0;k<3;k++)
               {
                   if(j==1 && k==0 || j==1 && k==1)
                   {
                       printf(\" \");
                   }
                   else
                   printf(\"#\");
               }
               printf(\"\ \");
           }  
       }
       else if(text[i]==\'U\')
       {
           for(j=0;j<3;j++)
           {
               for(k=0;k<3;k++)
               {
                   if(j==0 && k==1 || j==1 && k==1)
                   {
                       printf(\" \");
                   }
                   else
                   printf(\"#\");
               }
               printf(\"\ \");
           }
       }
       else if(text[i]==\'A\')
       {
           for(j=0;j<3;j++)
           {
               for(k=0;k<3;k++)
               {
                   if(j==1 && k==1 || j==2&& k==1)
                   {
                       printf(\" \");
                   }
                   else
                   printf(\"#\");
               }
               printf(\"\ \");
           }
       }
       else if(text[i]==\'C\')
       {
           for(j=0;j<3;j++)
           {
               for(k=0;k<3;k++)
               {
                   if(j==1 && k==1 || j==1 && k==2)
                   {
                       printf(\" \");
                   }
                   else
                   printf(\"#\");
               }
               printf(\"\ \");
           }
       }
       printf(\"\\b\");
       res=strcmp(text,text2);
       }
   }while(res!=0);
   return 0;
}

 Learning Objective: Use loops in C to make models of the real world. In living organisms, cells continually synthesize hundreds of thousands of different prote
 Learning Objective: Use loops in C to make models of the real world. In living organisms, cells continually synthesize hundreds of thousands of different prote

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site