Messing around
This commit is contained in:
14
charcount.c
Normal file
14
charcount.c
Normal 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);
|
||||||
|
}
|
||||||
6
getchar.c
Normal file
6
getchar.c
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
main (){
|
||||||
|
int c;
|
||||||
|
c='\0';
|
||||||
|
printf("%d\n",c);
|
||||||
|
}
|
||||||
BIN
temperature
Executable file
BIN
temperature
Executable file
Binary file not shown.
26
temperature.c
Normal file
26
temperature.c
Normal 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));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user