



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
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
Uploaded on 09/20/2020
5 documents
1 / 5
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. 13/
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):
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):
1/5/10/20 bills required to equal the total input.
#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; }