boisverd


Joined 1 year ago
Homeworks submitted:
Homework comments:
4
0

About Me

No description provided.

Classes

Bash Scripting

Class status: Established
Role: Student
. 0% complete

Programming in C

Class status: Established
Role: Student
. 8% complete

Submitted Assignments

Programming in C: Lesson 1, HW 4

My EOF check tested as 0 when EOF was reached and 1 when false. I included both exercises 6 and 7 in once simple program.

$>./filecopy.o < mytextfile.txt
The expression getchar() != EOF evaluates to: 1 when false.
ello, my name is Denis and I live in a house. My house is in Montreal and at night I eat dinner.
The value of check is: 0 when true.
EOF = -1

$>vim filecopy.c
  1 #include <stdio.h>
  2
  3 int main(void){
  4
  5      int c, check;
  6      system("clear");
  7      c = getchar() != EOF;
  8      printf("The expression getchar() != EOF evaluates to: %d when false.\n",c);
  9      while ((c = getchar()) != EOF )
 10           putchar(c);
 11
 12      check = getchar() != EOF; //save the value of the check
 13      printf("The value of check is: %d when true.\n",check); //print the value of the check
 14      printf("EOF = %d\n",EOF);
 15 }

boisverd 1 year ago
Programming in C: Lesson 1, HW 3
tempconvFor.c
  1 #include <stdio.h>
  2
  3 /*print fahrenheit-celsius table */
  4
  5 /* F = (9/5)*C+32 & C = (F-32) * (5/9) */
  6
  7 int main(){
  8
  9 int fahr;
 10
 11
 12 system("clear"); //linux bash shell screen clear function
 13 printf("Temperature Conversion Chart\n");
 14 printf("Celsius\tFahrenheit\n");
 15 for(fahr = 300; fahr >= 0; fahr = fahr - 20)
 16      printf("%7.2f\t%10d\n",(5.0/9.0)*(fahr - 32.0),fahr);
 17 }

./tempconvFor.o
Temperature Conversion Chart
Celsius Fahrenheit
 148.89        300
 137.78        280
 126.67        260
 115.56        240
 104.44        220
  93.33        200
  82.22        180
  71.11        160
  60.00        140
  48.89        120
  37.78        100
  26.67         80
  15.56         60
   4.44         40
  -6.67         20
 -17.78          0

boisverd 1 year ago
Programming in C: Lesson 1, HW 2
Ex1-3 tempconv.c
  1 #include <stdio.h>
  2
  3 /*print fahrenheit-celsius table */
  4
  5 /* F = (9/5)*C+32 & C = (F-32) * (5/9) */
  6
  7 int main(){
  8
  9 float fahr, celsius;
 10 int lower, upper, step;
 11
 12 lower = 0;
 13 upper = 200;
 14 step = 20;
 15
 16 fahr = lower;
 17 system("clear"); //linux bash shell screen clear function
 18 printf("Temperature Conversion Chart\n");
 19 printf("Fahrenheit\tCelsius\n");
 20 while ( fahr <= upper ){
 21      celsius = (fahr-32.0) * (5.0/9.0);
 22      printf("%10.2f\t%7.2f\n",fahr,celsius);
 23      fahr = fahr + step;
 24 }
 25 }

ex1-4
tempconv1.c
  3 /*print fahrenheit-celsius table */
  4
  5 /* F = (9/5)*C+32 & C = (F-32) * (5/9) */
  6
  7 int main(){
  8
  9 float fahr, celsius;
 10 int lower, upper, step;
 11
 12 lower = -20;
 13 upper = 100;
 14 step = 10;
 15
 16 celsius = lower;
 17 system("clear"); //linux bash shell screen clear function
 18 printf("Temperature Conversion Chart\n");
 19 printf("Celsius\tFahrenheit\n");
 20 while ( celsius <= upper ){
 21      fahr = (9.0/5.0*celsius) + 32.0;
 22      printf("%7.2f\t%10.2f\n",celsius,fahr);
 23      celsius = celsius + step;
 24 }
 25 }

boisverd 1 year ago
Programming in C: Lesson 1, HW 1

My output with an invalid escape sequence: champollion:/home/boisverd# gcc -o helloworld helloworld.c helloworld.c:5:9: warning: unknown escape sequence 'k'

Notice how the exclamation mark is not interpreted as a negation since it is within quotation marks inside the printf library function.

#include <stdio.h>

int main(){

        printf("Hello World!\k");
}

boisverd 1 year ago