Messing around

This commit is contained in:
2020-11-30 11:56:55 +02:00
parent 852583759c
commit 463eceae52
6 changed files with 46 additions and 0 deletions

BIN
charcount Executable file

Binary file not shown.

14
charcount.c Normal file
View File

@@ -0,0 +1,14 @@
#include <stdio.h>
main (){
int c, nb,nt,nl = 0;
while ((c = getchar()) != EOF)
{
if(c='\0')
++nb;
if(c='\t')
++nt;
if(c='\n')
++nl;
}
printf("\nThere are %d blanks, %d tabs, and %d new lines\n", nb,nt,nl);
}

BIN
getchar Executable file

Binary file not shown.

6
getchar.c Normal file
View File

@@ -0,0 +1,6 @@
#include <stdio.h>
main (){
int c;
c='\0';
printf("%d\n",c);
}

BIN
temperature Executable file

Binary file not shown.

26
temperature.c Normal file
View File

@@ -0,0 +1,26 @@
#include <stdio.h>
#define UPPER 300
#define LOWER 0
#define STEP 20
main()
{
float fahr, celsius ;
fahr = LOWER;
printf("%3s\t%6s\n", "Farenheit", "Celsius");
while (fahr <= UPPER) {
celsius = 5 * (fahr-32) / 9;
printf("%3.0f\t%6.1f\n", fahr, celsius);
fahr = fahr + STEP;
}
fahr, celsius = 0;
celsius = LOWER;
printf("%3s\t%6s\n", "Celsius", "Farenheit");
while (celsius <= UPPER ) {
fahr = (5.0/9.0) + (celsius + 32.0);
printf("%3.1f\t%6.0f\n", celsius, fahr);
celsius = celsius + STEP;
}
for (fahr = 300; fahr >= 0; fahr -= 20){
printf("%3.1f %6.1f\n", fahr, (5.0/9.0)*(fahr-32));
}
}