Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Learning Objective: Use loops in C to make models of the real world. In living o

ID: 3791838 • Letter: L

Question

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.

Explanation / Answer

#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("");
       res=strcmp(text,text2);
       }
   }while(res!=0);
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote