School Commit Init
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
//Knowing that we have coins of 1, 2 and 5 units, determine the minimum number of coins to pay a given amount.
|
||||
|
||||
#include<stdio.h>
|
||||
int main(){
|
||||
int n,ones,twos,fives;
|
||||
printf("Enter a number: ");
|
||||
scanf("%d",&n);
|
||||
fives=n/5;
|
||||
n%=5;
|
||||
twos=n/2;
|
||||
n%=2;
|
||||
ones=n;
|
||||
printf("The minimum number of coins required are: %d of 5's, %d of 2's and %d of 1's.\n ",fives,twos,ones);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
//Being given the values of the diagonals of a diamond shape (romb), compute the area and perimeter of the diamond shape.
|
||||
|
||||
#include<stdio.h>
|
||||
#include<math.h>
|
||||
int main(){
|
||||
float d1,d2,perimeter,area;
|
||||
printf("Please enter a number: ");
|
||||
scanf("%f",&d1);
|
||||
printf("Please enter another number: ");
|
||||
scanf("%f",&d2);
|
||||
perimeter=2*sqrtf(d1*d1+d2*d2);
|
||||
area=(d1*d2)/2;
|
||||
printf("The perimeter of a romb with diagonals %.2f and %.2f is: %.2f and the area is: %.2f.\n",d1,d2,perimeter,area);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user