910Lect code

This commit is contained in:
Haldrup-tech 2024-09-10 15:12:12 -04:00
parent 1762ad4c50
commit c82e8c8b27
3 changed files with 34 additions and 1 deletions

BIN
csci218/Assignments/mac.out Executable file

Binary file not shown.

View File

@ -6,7 +6,17 @@ I certify that this assignment is entirely my own work.
*/
#include <stdio.h>
void nameAge();
void countPennies();
int main(void) {
nameAge();
countPennies();
return 0;
}
void nameAge() {
printf("This program will take your name and age and see your age in 5 years\n");
//declare
char name[100];
@ -24,7 +34,30 @@ int main(void) {
//output and calculate
printf("Hi %s! In five years, you will be %d\n", name, age);
return 0;
}
void countPennies() {
//declare
printf("This program will calculate the number of pennies.\n");
int dollars, quarters, dimes, nickels, pennies, totalPennies;
//Input
printf("Enter number of dollars: ");
scanf("%d", &dollars);
printf("Enter number of quarters: ");
scanf("%d", &quarters);
printf("Enter number of dimes: ");
scanf("%d", &dimes);
printf("Enter number of nickels: ");
scanf("%d", &nickels);
printf("Enter number of pennies: ");
scanf("%d", &pennies);
//calculate
totalPennies = (dollars * 100) + (quarters * 25) + (dimes * 10) + (nickels * 5) + pennies;
//Display
printf("Total Pennies: %d\n", totalPennies);
}

Binary file not shown.