@ -0,0 +1,17 @@ | |||||
#include <stdio.h> | |||||
#include <string.h> | |||||
int main (void) { | |||||
float number; | |||||
printf("Give a float number: "); | |||||
scanf("%g", &number); | |||||
printf("The input is %.1f or %.1e\n", number, number); | |||||
printf("The input is %+.3f or %.3e\n", number, number); | |||||
return 0; | |||||
} |
@ -0,0 +1,19 @@ | |||||
#include <stdio.h> | |||||
#include <string.h> | |||||
int main (void) { | |||||
float height; | |||||
char name[21]; | |||||
printf("Give your heigth in cm: "); | |||||
scanf("%f", &height); | |||||
printf("Give your name: "); | |||||
scanf("%20s", name); | |||||
printf("%s, you are %.3f m tall\n", name, height/100); | |||||
return 0; | |||||
} |
@ -0,0 +1,20 @@ | |||||
#include <stdio.h> | |||||
#include <string.h> | |||||
int main (void) { | |||||
float speed; | |||||
float size; | |||||
printf("Give download speed in Mbit/s: "); | |||||
scanf("%f", &speed); | |||||
printf("Give file size in Mbytes: "); | |||||
scanf("%f", &size); | |||||
printf("At %.2f megaits per second, a file of %.2f megabytes\n", speed, size); | |||||
printf("downloads in %.2f seconds\n", size*8/speed); | |||||
return 0; | |||||
} |
@ -0,0 +1,22 @@ | |||||
#include <stdio.h> | |||||
#include <string.h> | |||||
int main (void) { | |||||
char first_name[21]; | |||||
char last_name[21]; | |||||
printf("Give your first name: "); | |||||
scanf("%20s", first_name); | |||||
printf("Give your last name: "); | |||||
scanf("%20s", last_name); | |||||
printf("%s %s\n", first_name, last_name); | |||||
printf("%*lu %*lu\n", (int)strlen(first_name), strlen(first_name), (int)strlen(last_name), strlen(last_name)); | |||||
printf("%s %s\n", first_name, last_name); | |||||
printf("%-*lu %-*lu\n", (int)strlen(first_name), strlen(first_name), (int)strlen(last_name), strlen(last_name)); | |||||
return 0; | |||||
} |