update C
snipplets
This commit is contained in:
11
code/C/Transform/rgbToHex.c
Normal file
11
code/C/Transform/rgbToHex.c
Normal file
@@ -0,0 +1,11 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char const *argv[]) {
|
||||
int red = 0;
|
||||
int green = 128;
|
||||
int blue = 64;
|
||||
|
||||
printf("#%.2x%.2x%.2x\n", red, green, blue); // #008040
|
||||
|
||||
return 0;
|
||||
}
|
11
code/C/Transform/seconds_to_minutes_and_hours.c
Executable file
11
code/C/Transform/seconds_to_minutes_and_hours.c
Executable file
@@ -0,0 +1,11 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char const *argv[]) {
|
||||
unsigned int seconds = 800000 + 61;
|
||||
unsigned int minutes = seconds / 60;
|
||||
unsigned int hours = minutes / 60;
|
||||
|
||||
printf("H: %d\nM: %d\nS: %d\n", hours, minutes % 60, seconds % 60);
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user