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

1500 pts for Marie Code While Loop Please help me.STILL NEED ANSWERS!- Also for

ID: 3567210 • Letter: 1

Question

1500 pts for Marie Code While Loop Please help me.STILL NEED ANSWERS!- Also for Full amount of points you need to Make comments out to the side of each line of the code explaining what each line is doing so I can study and learn from it. Thank you.

Using Marie Instruction Set from Table 4.2 on page 234 Write a program that will implement the following algorithm: create a memory location named Sum and set it equal to 0 create a memory location named P and set it equal to 0 create a memory location named N and set it equal to a decimal 20 write the code for the following: input from the keyboard a value that is greater than 0 store time value in P while N> 5 { Sum = Sum + P; N = N - P; output that is stored in Sum } end while Here is a Hint - The while loop is a pre-check loop. You must check the condition N > 5 before entering the loop

Explanation / Answer


       //C-code of algorithm
       #include<stdio.h>
       int main()
       {
      
       //C-code of the algorithm
       float sum=0;
       float P=0;
       int N=20;
      
       printf("Enter a number(>5)");
       scanf("%f",&P);
      
       //while condition checks whether P is greater
       //than 5 or not . If so, continues the loop
       while(P>5)
       {
           //the statement adds the sum to the value
           //which is entered by the user and assign
           //the value to the sum variable by overwrite
           //the sum value.
           sum=sum+P;
           //subtract the P value from N wich 20 and overwrite
           //the result to N variable
           N=N-P;
           //The statement prints the sum value stored
           //in sum variable
           pritnf("%f",sum);
          
       }
      
       return 0;
       }//end of main method

------------------------------------------------------------------------

Sample output:

Note: The while loop executes infinite times if P is greater than 5 value.

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