Browse Source

Add Makefile & last two exercises of chapter 03

master
T. Meissner 9 years ago
parent
commit
b389a7e623
3 changed files with 55 additions and 0 deletions
  1. +17
    -0
      c_primer_plus/chapter03/07.c
  2. +24
    -0
      c_primer_plus/chapter03/08.c
  3. +14
    -0
      c_primer_plus/chapter03/Makefile

+ 17
- 0
c_primer_plus/chapter03/07.c View File

@ -0,0 +1,17 @@
#include <stdio.h>
#define CM_PER_INCH 2.54
int main (void) {
float inches;
printf("Enter your height in inches: ");
scanf("%f", &inches);
printf("Your height in cm is %.2f\n", inches * CM_PER_INCH);
return 0;
}

+ 24
- 0
c_primer_plus/chapter03/08.c View File

@ -0,0 +1,24 @@
#include <stdio.h>
int main (void) {
float cups;
printf("Give a volume in cups: ");
scanf("%f", &cups);
float pints = cups / 2;
float ounces = cups * 8;
float tablespoons = ounces * 2;
float teaspoons = tablespoons * 3;
printf("The given volume are %0.2f pints\n", pints);
printf("The given volume are %0.2f ounces\n", ounces);
printf("The given volume are %0.2f tablespoons\n", tablespoons);
printf("The given volume are %0.2f teaspoons\n", teaspoons);
return 0;
}

+ 14
- 0
c_primer_plus/chapter03/Makefile View File

@ -0,0 +1,14 @@
SRC := $(shell ls *.c)
.PHONY: all
all:
%: %.c
gcc -Wall -Wextra $@.c -o $@
.PHONY: clean
clean:
@rm -f ??

Loading…
Cancel
Save