Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Laboratory works for Assembly language programming., Assignments of Assembly Language Programming

Assembly language is covered. For Computer Engineering students.

Typology: Assignments

2019/2020

Uploaded on 09/20/2020

unknown user
unknown user 🇬🇪

5 documents

1 / 8

Toggle sidebar

Related documents


Partial preview of the text

Download Laboratory works for Assembly language programming. 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. 20/2019 [Lab Assignment #5] [Compound Interest, Red ID even/odd, Prime Check] COMPE-160 Emrashvili Luka 823355800 EMRASHVILI LUKA 823355800 [LAB ASSIGNMENT #5] Part 1 . ( Compound Interest) A) (using double); 1. Description of the Problem / Method: 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. 2. Pseudocode: 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 3. C-code: #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: "); EMRASHVILI LUKA 823355800 [LAB ASSIGNMENT #5] Part 2. ( Red ID even/odd) 1. Description: We have to write a program that asks for numeric input and indicates if the digits from an input are even or odd. 2. Pseudocode: 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”. 3. C-code: #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"); } EMRASHVILI LUKA 823355800 [LAB ASSIGNMENT #5] } return 0; } 4. Screen capture of the code and the resulting display(s): EMRASHVILI LUKA 823355800 [LAB ASSIGNMENT #5] Part 3. ( Prime Check) 1. Description: 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. 2. Pseudocode: 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; 3. C-code: #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) {
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved