Lab #3 in COMPE-160: Integer & Float Polynomial Calculations, Assignments of Assembly Language Programming

The solutions for lab assignment #3 in the compe-160 course at san diego state university. The assignment required writing c-code to calculate the sum of digits of an integer, evaluate and print the value of a polynomial ax2 + bx + c for integer and float inputs.

Typology: Assignments

2019/2020

Uploaded on 09/20/2020

unknown user
unknown user 🇬🇪

5 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
I declare that all material in this assignment is my own work except where there is
clear reference to the work of others.
I have read, understood and agree to the SDSU Policy on Plagiarism and
Cheating on the university website at
http://go.sdsu.edu/student_affairs/srr/cheating-plagiarism.aspx and the
syllabus for the consequences of plagiarism, including both academic and
punitive sanctions.
___________________________________________________________________
Remark*. By submitting this assignment report electronically, you are deemed to have signed the
declaration above.
[Lab Assignment #3]
[Red ID Sum]
COMPE-160
Click below to enter/change your Name and RedID
Emrashvili Luka 823355800
pf3
pf4

Partial preview of the text

Download Lab #3 in COMPE-160: Integer & Float Polynomial Calculations and more Assignments Assembly Language Programming in PDF only on Docsity!

 I declare that all material in this assignment is my own work except where there is clear reference to the work of others.  I have read, understood and agree to the SDSU Policy on Plagiarism and Cheating on the university website at http://go.sdsu.edu/student_affairs/srr/cheating-plagiarism.aspx and the syllabus for the consequences of plagiarism, including both academic and punitive sanctions.


Remark*. By submitting this assignment report electronically, you are deemed to have signed the declaration above.

[Lab Assignment #3]

[Red ID Sum]

COMPE-

Click below to enter/change your Name and RedID

Emrashvili Luka 823355800

Part 1)

1. We have to write a program that uses scanf() to input a decimal integer, calculate the sum of the digits of the written decimal integer, and, finally, use printf() to print the sum of the digits 2. C-code: #include <stdio.h> #include <stdlib.h> int main() { int n, sum = 0; printf ("Enter an integer: "); scanf ("%d", &n); printf ("\n"); while (n != 0) { sum = sum + n%10; n = n / 10; } printf ("Sum of the digits for the number entered = %d\n", sum); return 0; }

Part 3)

1. We have to write a program that evaluates and prints the value of the polynomial ax^2 + bx + c,

given user inputs for a, b, c, and x. But, at this time we have to use float variables.

2. C-code:

#include <stdio.h> #include <stdlib.h> int main() { double a, b, c, x, value; printf("a b c x : "); scanf("%lf", &a); scanf("%lf", &b); scanf("%lf", &c); scanf("%lf", &x); value = a * x * x + b * x + c; printf("The value of the polynomial = %lf", value); return 0; }