Write in C language to compute the following Write an assembly language program
ID: 3667139 • Letter: W
Question
Write in C language to compute the following
Write an assembly language program to compute the following equation : y- sigma^5_x=-5 x^3+4x^2-13x Print out a message at the end stating the final value of y. Make sure to define the coefficients 4 and 13 as constants a1 and a2 Try to eliminate as many nop instructions as possible and also try to minimize length of your code. Requirements: Follow the requirements as described above. Name your source file lastname2.m-nano lastname2.m or use another editor To expand the macros and to create the s.file, run:m4 lastname2.m>lastname.s To compile the code and create an executable, use: gcc-o-lastname2 lastname2.s To run the program, type: /lastname2Explanation / Answer
#include<stdio.h>
main()
{
int y=0, a1=4, a2= 13, x;
for(x=-5;x<=5;x++) //This will execute loop through range of values from -5 to 5 for variable x
y=y + x*x*x + a1*x*x - a2*x; //this would compute the expression x*x*x + 4*x*x - 13*x
printf("The value of y is: %d",y);
}
Hope it helps. :-)
If you have any confusion or query, please leave a comment I’ll try to explain in more details.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.