Download int i = 1

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Falcon (programming language) wikipedia , lookup

Object-oriented programming wikipedia , lookup

Functional programming wikipedia , lookup

Computer cluster wikipedia , lookup

JavaScript syntax wikipedia , lookup

Data-intensive computing wikipedia , lookup

C Sharp (programming language) wikipedia , lookup

Supercomputer architecture wikipedia , lookup

Supercomputer wikipedia , lookup

Transcript
Basic
COMPUTING
FOR A=1 TO 100
IF A MOD 15 = 0 THEN
PRINT “FizzBuzz”
ELSE IF A MOD 3 = 0 THEN
PRINT “Fizz”
ELSE IF A MOD 5 = 0 THEN
PRINT “Buzz”
ELSE
PRINT A
END IF
NEXT A
First appeared
Popular uses
Main paradigms
Features
1964
Computer Science,
Education,
Scripting, Games
Imperative,
Object Oriented
(some variations)
Simple,
Many
Implementations
C
COMPUTING
http://www.cprogramming.com/tutorial.html
#include <stdio.h>
int main (int argc, char** argv)
{
int i;
for (i = 1; i <= 100; i++)
{
if (!(i % 15))
printf("FizzBuzz\n");
else if (!(i % 3))
printf("Fizz\n");
else if (!(i % 5))
printf("Buzz\n");
else
printf("%d\n", i);
}
return 0;
}
First appeared
1972
Popular uses
Main paradigms
Features
Operating Systems,
Compilers,
Interpreters,
Embedded
Processors, Games
Imperative,
Static Typing
High Performance,
Low Level,
Pervasive
Scheme
COMPUTING
http://www.schemers.org
(define (fizzify i)
(cond
((= (modulo i 15) 0) "FizzBuzz")
((= (modulo i 3) 0) "Fizz")
((= (modulo i 5) 0) "Buzz")
(#t i)
)
)
(define (fizzbuzz i)
(if (<= i 100)
(begin
(display (fizzify i)) (display "\n")
(fizzbuzz (+ i 1))
)
)
)
(fizzbuzz 1)
First appeared
Popular uses
Main paradigms
Features
1975
Computer Science
Education,
Scripting,
Academic Research
Functional,
Tail Call Recursion,
Dynamic Typing
Homoiconic,
Minimalistic,
Cross Platform
Python
COMPUTING
http://www.python.org
for i in range(1, 101):
if i % 15 == 0:
print "FizzBuzz"
elif i % 3 == 0:
print "Fizz"
elif i % 5 == 0:
print "Buzz"
else:
print( i )
First appeared
Popular uses
Main paradigms
Features
1991
Computer Science
Education,
Scripting,
Internet, Games
Imperative,
Object Oriented,
Dynamic Typing
Cross Platform,
Duck Typing,
Indentation
Syntax,
Interpreter
Java
COMPUTING
http://www.java.com
public class FizzBuzz
{
public static void main (String[] args)
{
for (int i = 1; i <= 100; i++)
{
if (i % 15 == 0) {
System.out.println("FizzBuzz");
} else if (i % 3 == 0) {
System.out.println("Fizz");
} else if (i % 5 == 0) {
System.out.println("Buzz");
} else {
System.out.println(i);
}
}
}
}
First appeared
1995
Popular uses
Main paradigms
Features
Applications,
Mobile Devices,
Compilers,
Interpreters,
Games
Imperative,
Object Oriented,
Static Typing,
Generics
Interoperability,
Standardised,
Cross Platform
Ruby
COMPUTING
http://www.ruby-lang.org
1.upto(100) do |n|
print "Fizz" if a = (n % 3).zero?
print "Buzz" if b = (n % 5).zero?
print n unless (a || b)
print "\n"
end
First appeared
1995
Popular uses
Main paradigms
Features
Internet, Scripting
Imperative,
Object Oriented,
Dynamic Typing,
Functional
Cross Platform,
Duck Typing
C#
COMPUTING
using System;
namespace FizzBuzz
{
class Program
{
static void Main(string[] args)
{
for (int i = 1; i <= 100; i++)
{
string output = "";
if (i % 3 == 0) output += "Fizz";
if (i % 5 == 0) output += "Buzz";
if (String.IsNullOrEmpty(output))
output = i.ToString();
Console.WriteLine(output);
}
}
}
}
First appeared
Popular uses
Main paradigms
Features
2001
Applications,
Internet,
Business, Games
Imperative,
Object Oriented,
Static Typing
Standardised,
Common
Language
Runtime
Scratch
COMPUTING
http://scratch.mit.edu/
First appeared
2007
Popular uses
Main paradigms
Features
Computer Science
Education
Fixed Function,
Imperative,
Visual
Programming
Rich Media,
Online
Collaboration,
Animation,
Cross Platform
PHP
COMPUTING
http://www.php.net
<?php
for(a = 1; a <= 100; a++) {
if(a % 15 == 0)
echo “FizzBuzz”;
elsif(a % 3 == 0)
echo “Fizz”;
elsif(a % 5 == 0)
echo “Buzz”;
}
?>
First appeared
Popular uses
Main paradigms
Features
1995
Computer Science,
Education, Internet,
Scripting
Imperative,
Object Oriented,
Dynamic Typing
Cross Platform,
Interpreter
Java Script
COMPUTING
for (a=1; a<=100; a++)
if(a%15 ===0){
console.log("FizzBuzz");
} else if ( a % 3 === 0 ) {
console.log("Fizz");
} else if (a % 5 === 0 ) {
console.log("Buzz");
} else {
console.log(a);
}
}
First appeared
Popular uses
Main paradigms
Features
1995
Web Pages,
PDF,
Widgets
Scripting,
Object Oriented,
Imperative,
Functional
Weakly Typed,
Cross Platform
Visual
Basic.net
COMPUTING
For a = 1 To 100
If a Mod 15 = 0 Then
Console.WriteLine("FizzBuzz")
ElseIf a Mod 5 = 0 Then
Console.WriteLine("Buzz")
ElseIf a Mod 3 = 0 Then
Console.WriteLine("Fizz")
Else
Console.WriteLine(a)
End If
Next
First appeared
Popular uses
Main paradigms
Features
2001
General purpose.
Office applications
and tools.
Gaming.
Structured,
Imperative,
Object Oriented,
Declarative
Intuative forms
designer.
Simple syntax.
Flexible.
Pascal
COMPUTING
program fizzbuzz(output);
var
a: integer;
begin
for a := 1 to 100 do
if a mod 15 = 0 then
writeln('FizzBuzz')
else if a mod 3 = 0 then
writeln('Fizz')
else if a mod 5 = 0 then
writeln('Buzz')
else
writeln(a)
end.
First appeared
1968
Popular uses
Main paradigms
Features
Education
Imperative,
Structured
Easy to learn.
Encourages good
style.
COBOL
COMPUTING
IDENTIFICATION DIVISION.
PROGRAM-ID. fizzbuzz.
DATA DIVISION.
WORKING-STORAGE SECTION
01 CNT PIC 9(03) VALUE 1.
01 REM PIC 9(03) VALUE 0.
01 QUOTIENT PIC 9(03) VALUE 0.
PROCEDURE DIVISION.
*PERFORM UNTIL CNT > 100
DIVIDE 15 INTO CNT GIVING QUOTIENT REMAINDER REM
IF REM = 0
THEN
DISPLAY "FizzBuzz " WITH NO ADVANCING
ELSE
DIVIDE 3 INTO CNT GIVING QUOTIENT REMAINDER REM
IF REM = 0
THEN
DISPLAY "Fizz " WITH NO ADVANCING
ELSE
DIVIDE 5 INTO CNT GIVING QUOTIENT REMAINDER REM
IF REM = 0
THEN
DISPLAY "Buzz " WITH NO ADVANCING
ELSE
DISPLAY CNT " " WITH NO ADVANCING
END-IF
END-IF
END-IF
ADD 1 TO CNT
END-PERFORM
DISPLAY "“
STOP RUN.
First appeared
1959
Popular uses
Main paradigms
Features
Business Processes
Batch Programming
Procedural,
Object Oriented
Verbose so more
like a natural
language
Perl
COMPUTING
foreach (1 .. 100) {
if (0 == $_ % 15) {
print "FizzBuzz\n";
} elsif (0 == $_ % 3) {
print "Fizz\n";
} elsif (0 == $_ % 5) {
print "Buzz\n";
} else {
print "$_\n";
};
};
First appeared
Popular uses
Main paradigms
Features
1987
Text Processing
Scripting
Graphics
Networking
Functional,
Imperative,
Object Oriented,
Procedural
Reusable Modules
Dynamic
Conversion
BBC Basic
COMPUTING
FOR a% = 1 TO 100
CASE TRUE OF
WHEN a% MOD 15 = 0: PRINT "FizzBuzz"
WHEN a% MOD 3 = 0: PRINT "Fizz"
WHEN a% MOD 5 = 0: PRINT "Buzz"
OTHERWISE: PRINT ; a%
ENDCASE
NEXT a%
First appeared
1981
Popular uses
Main paradigms
Features
Education
Gaming
Procedural
Weakly typed
Widely supported
Algol
COMPUTING
main:(
FOR a TO 100 DO
printf(($gl$,
IF a %* 15 = 0 THEN
"FizzBuzz"
ELIF a %* 3 = 0 THEN
"Fizz"
ELIF a %* 5 = 0 THEN
"Buzz"
ELSE
a
FI
))
OD
)
First appeared
Popular uses
Main paradigms
Features
1958
Research
Publishing
Algorithms
Procedural,
Imperative,
Structured
No easy
input/output