1 / 16

Basic

Basic. 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. 1964. Simple, Many Implementations. Computer Science, Education, Scripting, Games.

matt
Télécharger la présentation

Basic

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Basic FOR A=1 TO 100 IF AMOD15=0 THEN PRINT “FizzBuzz” ELSE IF AMOD3=0 THEN PRINT “Fizz” ELSE IF AMOD5=0 THEN PRINT “Buzz” ELSE PRINT A END IF NEXT A 1964 Simple, Many Implementations Computer Science, Education, Scripting, Games Imperative, Object Oriented (some variations)

  2. C #include <stdio.h> int main (intargc, char** argv) { inti; 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; } 1972 High Performance, Low Level, Pervasive Operating Systems, Compilers, Interpreters, Embedded Processors, Games Imperative, Static Typing http://www.cprogramming.com/tutorial.html

  3. Scheme (define (fizzifyi) (cond ((= (modulo i15) 0) "FizzBuzz") ((= (modulo i3) 0) "Fizz") ((= (modulo i5) 0) "Buzz") (#t i) ) ) (define (fizzbuzzi) (if (<=i100) (begin (display (fizzifyi)) (display "\n") (fizzbuzz (+i1)) ) ) ) (fizzbuzz1) 1975 Homoiconic, Minimalistic, Cross Platform Computer Science Education, Scripting, Academic Research Functional, Tail Call Recursion, Dynamic Typing http://www.schemers.org

  4. Python for i in range(1, 101): if i%15==0: print "FizzBuzz" elifi%3==0: print "Fizz" elifi%5==0: print "Buzz" else: print( i ) 1991 Cross Platform, Duck Typing, Indentation Syntax, Interpreter Computer Science Education, Scripting, Internet, Games Imperative, Object Oriented, Dynamic Typing http://www.python.org

  5. Java 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); } } } } 1995 Interoperability, Standardised, Cross Platform Applications, Mobile Devices, Compilers, Interpreters, Games Imperative, Object Oriented, Static Typing, Generics http://www.java.com

  6. Ruby 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 1995 Cross Platform, Duck Typing Internet, Scripting Imperative, Object Oriented, Dynamic Typing, Functional http://www.ruby-lang.org

  7. C# 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); } } } } 2001 Standardised, Common Language Runtime Applications, Internet, Business, Games Imperative, Object Oriented, Static Typing

  8. Scratch 2007 Rich Media, Online Collaboration, Animation, Cross Platform Computer Science Education Fixed Function, Imperative, Visual Programming http://scratch.mit.edu/

  9. PHP <?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”; } ?> 1995 Cross Platform, Interpreter Computer Science, Education, Internet, Scripting Imperative, Object Oriented, Dynamic Typing http://www.php.net

  10. Java Script 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); } } 1995 Weakly Typed, Cross Platform Web Pages, PDF, Widgets Scripting, Object Oriented, Imperative, Functional

  11. Visual Basic.net Fora = 1To100IfaMod15 = 0ThenConsole.WriteLine("FizzBuzz")ElseIfaMod5 = 0ThenConsole.WriteLine("Buzz")ElseIfaMod3 = 0ThenConsole.WriteLine("Fizz")ElseConsole.WriteLine(a)End If Next 2001 Intuative forms designer. Simple syntax. Flexible. General purpose. Office applications and tools. Gaming. Structured, Imperative, Object Oriented, Declarative

  12. Pascal programfizzbuzz(output); vara: integer; beginfora := 1to100doifamod15 = 0thenwriteln('FizzBuzz')else ifamod3 = 0thenwriteln('Fizz')else ifamod5 = 0thenwriteln('Buzz')elsewriteln(a) end. 1968 Easy to learn. Encourages good style. Education Imperative, Structured

  13. COBOL 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. 1959 Verbose so more like a natural language Business Processes Batch Programming Procedural, Object Oriented

  14. Perl foreach (1 .. 100) {if (0 == $_ % 15) { print "FizzBuzz\n";} elsif (0 == $_ % 3) { print "Fizz\n";} elsif (0 == $_ % 5) { print "Buzz\n";} else { print "$_\n";}; }; 1987 Reusable Modules Dynamic Conversion Text Processing Scripting Graphics Networking Functional, Imperative, Object Oriented, Procedural

  15. BBC Basic FORa% = 1TO100CASE TRUE OFWHENa%MOD15 = 0: PRINT"FizzBuzz"WHENa%MOD3 = 0: PRINT"Fizz"WHENa%MOD5 = 0: PRINT"Buzz"OTHERWISE: PRINT ; a%ENDCASE NEXTa% 1981 Weakly typed Widely supported Education Gaming Procedural

  16. Algol main:(FORaTO100DOprintf(($gl$,IFa %* 15 = 0THEN"FizzBuzz"ELIFa %* 3 = 0THEN"Fizz"ELIFa %* 5 = 0THEN"Buzz"ELSEaFI ))OD) 1958 No easy input/output Research Publishing Algorithms Procedural, Imperative, Structured

More Related