instructional systems
Index:
[Session12] JavaScript 2 (Basic syntax, control structure (if, for, etc.))
1 Chapter1
2 Chapter2
3 Chapter3
4 Chapter4
5 Chapter5
Your Location: Home Page  >  [3] Interactive web pages using JavaScript (on condition)  >  [Session12]JavaScript 2 (Basic syntax, control structure (if, for, etc.))  >  Chapter5  >  5.1 Programming samples of languages other than JavaScript.
Programming samples of languages other than JavaScript.

--- C言語 ---

#include <stdio.h>
main(){
    int k, m;
    for(k = 1;  k < 26;  k = k + 1){
        m = k%4;
        if (m == 0){
            printf("%d",k);
            printf("\n");
        }
    }
}

--- Perl ---

for($k = 1;  $k < 26;  $k = $k + 1){
    $m = $k%4;
    if ($m == 0){
        printf("%d",$k);
        printf("\n");
    }
}

--- Java ---

class prog5 {
    public static void main (String argv[]) {
        int k, m;
        for(k = 1;  k < 26;  k = k + 1){
            m = k%4;
            if (m == 0){
                System.out.print(k+"");
                System.out.print("\n");
            }
        }
    }
}

--- FORTRAN ---

      PROGRAM PROG5
      DO 10, K=1,25
      M=K-(K/4)*4
      IF(M.EQ.0) WRITE (*,*) K
   10 CONTINUE
      STOP
      END
Copyright (c) Toshihiro Kita 2002, All Rights Reserved