Programming Languages

These sessions are:

Resources



Sequence


C

hello

#include <stdio.h>
int main () {
   int i;
   i = 3;
   i = i + 5;
   printf("Hello %d\n", i)
}


Web

CGI bin
 
https://en.wikipedia.org/wiki/Common_Gateway_Interface

Beyond the scope

floating point math

#include <stdio.h>
#include <math.h>
int main() {
    float j;
    j = sin(M_PI / 4);
    printf("%3.3f\n", j);
}


Python

Hello

i = 3
i = i + 5
print ("Hello %d" %(i))

web

mod_python  mod_wsgi

https://en.wikipedia.org/wiki/Mod_wsgi

Beyond the scope

floating point math

import math
j = math.sin(math.pi/4)
print ("%6.3f" %(j))



Shell

Hello

i=3

i=$[$i+5]

echo "Hello $i"

Web

CGI bin


Beyond the scope

floating point math

Don't be silly

or if you must:


perl -e 'use Math::Trig;
printf("%6.3f\n", sin(pi/4));'


php

Hello


<?php
$i = 3;

$i = $i + 5;

echo "Hello $i";

Web

<?php

$file = basename($_SERVER['PHP_SELF']);

?>

<form method=get action=<?php echo $file; ?>>

<input type=text name='i'>


<?php

echo $_GET['i'];

Floating point math

<?php

$j = sin(pi()/4);

echo round($j, 3)."\n";

?>



Hands On

Copy the the hello examples for all 4 languages into 4 files:

Run the programs

Modify 

Things to debate - we can do this for the entire Fall and Winter.

Home Work