Compare commits

..

4 Commits

6 changed files with 43 additions and 1 deletions

View File

@ -12,7 +12,7 @@ int main()
tModifier = (5.0/9.0);
while (fahr <= UPPER) {
celsius = tModifier * (fahr - 32.0);
printf("%3.0f\t%5.1f\n", fahr, celsius);
printf("%3.0f°F\t%5.1f°C\n", fahr, celsius);
fahr = fahr + STEP;
}
}

View File

@ -0,0 +1,2 @@
all:
gcc -o character-io.x86_64 main.c

View File

@ -0,0 +1,11 @@
#include <stdio.h>
void main()
{
int c;
while ((c = getchar()) != EOF) {
putchar(c);
printf("%d", EOF);
}
}

View File

@ -0,0 +1,2 @@
all:
gcc -o word-count.x86_64 main.c

View File

@ -0,0 +1,27 @@
#include <stdio.h>
#define IN 1
#define OUT 0
/* count lines, words, and characters in user input */
int main()
{
int c, nl, nw, nc, state;
state = OUT;
nl = nw = nc = 0;
while ((c = getchar()) != EOF) {
++nc;
if (c == '\n')
++nl;
if (c == ' ' || c == '\n' || c == '\t')
state = OUT;
else if (state == OUT) {
state = IN;
++nw;
}
}
printf("number of lines: %d\n", nl);
printf("number of words: %d\n", nw);
printf("number of chars: %d\n", nc);
}