




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Assembly language is covered. For Computer Engineering students.
Typology: Assignments
Uploaded on 09/20/2020
5 documents
1 / 8
This page cannot be seen from the preview
Don't miss anything!





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. 20/
[Compound Interest, Red ID even/odd, Prime Check]
We have to write a program, which will compute compounded interest. We must print what the account value will be at the end of each year with different compounding periods (daily, weekly, monthly, quarterly, Annually) and must use data type double for money.
Declare double variables: initialAmount, interestRate, DailyAmount, WeeklyAmount, MonthlyAmount, QuarterlyAmount and YearlyAmount; Declare an integer variables i and numYears; Step 1: Request initial Account balance, interest rate in percent and number of years from the user as an input; Step 2: Print the titile of the table: printf("Year Daily Weekly Monthly Quarterly Annually\n"); printf("---- ------- -------- --------- ----------- ----------\n"); Step 3: Print initial values; FOR iteration bounds from 1 to numYears; initialize variable i with 1; update values of Daily Amount, Weekly Amount, Monthly Amount, Quarterly Amount and Yearly Amount; print each calculated value; update value of initial Amount; FOREND
#include <stdio.h> #include <stdlib.h> int main() { double initialAmount, interestRate, dailyAmount=0, weeklyAmount=0, monthlyAmount=0, quarterlyAmount=0, annualyAmount=0; int I, numYears; printf ("Enter initial account balance: "); scanf ("%lf", &initialAmount); printf ("\nEnter the annual interest in percent: "); scanf ("%lf", &interestRate); printf ("\nEnter number of years: ");
3. Screen capture of the code and the resulting display for the last 6 digits of my red Id number:
We have to write a program that asks for numeric input and indicates if the digits from an input are even or odd.
Declare a string variable redid with a length 9 and an integer variable i; Request from user to input his / her red id number; Read the entered number; Print the title of the table; Initialize i with 0 and consider iterating bounds [0,9); Print “Even” if digits of the number are: 0, 2, 4, 6, 8; Otherwise print “Odd”.
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char redId[9]; int i; printf("Input your Red ID: "); scanf("%s", redId); printf("n odd / even\n"); printf("-- ------------\n"); for (i = 0; i < 9; ++i) { printf("%c ", redId[i]); if (redId[i] == '0'||redId[i] == '2'||redId[i] == '4'||redId[i] == '6'||redId[i] == '8' ) { printf("Even\n"); } else { printf("Odd\n"); }
We have to write a program that indicates if a number input is a prime number or not. The program shout continue until the user enters 0 to exit.
Declare an integer variables Number, i, and divisor, which is initialized to 0; Request an input number from the user; Read the entered number; Initialize i with 2 and consider iterating bounds [2, Number/2); Print “is a prime number” if the number have no divisor except 1; Print “is not a prime number” if the number have at least 1 divisor except 1;
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> int main() { int Number; int i; int divisor = 0; printf("Enter a number: "); scanf("%d", &Number); for (i=2; i <= Number/2; ++i) { if (Number %i == 0) { ++divisor; break; } } if (divisor == 0 && Number != 1) { printf("%d is a prime number.", Number); } else if (divisor == 0 && Number == 1) {
printf("%d is neither a prime nor composite number.", Number); } else { printf("%d is not a prime number.", Number); } return 0; }