C Programming Lab Assignment 4: Loops, Assignments of Assembly Language Programming

A lab assignment for a C programming course, where students are required to write programs using different types of loops to print a right triangle and calculate the number of bills required to make up a given amount.

Typology: Assignments

2019/2020

Uploaded on 09/20/2020

unknown user
unknown user 🇬🇪

5 documents

1 / 5

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.
13/2019
[Lab Assignment #4]
[Loops]
COMPE-160
Emrashvili Luka 823355800
pf3
pf4
pf5

Partial preview of the text

Download C Programming Lab Assignment 4: Loops 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. 13/

[Lab Assignment #4]

[Loops]

COMPE-

Emrashvili Luka 823355800

Part 1)

1. We have to write a program, without using any control structures like while or for, to print the right triangle with “”-s. 2. C-code: #include <stdio.h> #include <stdlib.h> int main() { printf("\n"); printf("\n"); printf("*\n"); printf("****\n"); printf("*****\n"); printf("******\n"); printf("*******\n"); printf("********\n"); printf("*********\n"); printf("**********\n"); return 0; } 3. Screen capture of the code and the resulting display(s):

b)Using for loops:

2)C-code: #include <stdio.h> #include <stdlib.h> int main() { int i; int j; for ( i = 0; i < 10; ++i ) { for ( j = 0; j <= i; ++j ) { printf("*"); } printf("\n"); } return 0; } 3) Screen capture of the code and the resulting display(s):

Part 3)

1. We have to write a program that will input a purchase amount, and display the number of

1/5/10/20 bills required to equal the total input.

2. C-code:

#include <stdio.h> #include <stdlib.h> int main() { int amount; scanf("%d", &amount); printf ("20 bills: %d\n", amount/20); amount = amount%20; printf ("10 bills: %d\n", amount/10); amount = amount%10; printf (" 5 bills: %d\n", amount/5); amount = amount%5; printf (" 1 bills: %d\n", amount/1); return 0; }

3. Screen capture of the code and the resulting display(s):