Extension for Source Code Display

From MIT Technology Roadmapping
Jump to navigation Jump to search

Source Code can be Shown in formatted fashions

JavaScript

<source lang="javascript" line start="1" highlight="4-6"> // SyntaxHighlighter makes your code snippets beautiful without tiring your servers. // http://alexgorbatchev.com var setArray = function(elems) {

   this.length = 0;
   push.apply(this, elems);
   return this;

} </source>

Please see the implementation

<source lang="HTML"> <source lang="javascript" line start="1" highlight="4-6"> // SyntaxHighlighter makes your code snippets beautiful without tiring your servers. // http://alexgorbatchev.com var setArray = function(elems) {

   this.length = 0;
   push.apply(this, elems);
   return this;

} </source>

Mathematica

<source language = "Mathematica"> fibonacciSequence[n_] :=

   Module[{fPrev = 0, fNext = 1, i = 0}, 
   While[i++ < n, {fPrev, fNext} = {fNext, fPrev + fNext}];

fNext] </source>

Please see the implementation

<source lang="HTML"> <source language = "Mathematica"> fibonacciSequence[n_] :=

   Module[{fPrev = 0, fNext = 1, i = 0}, 
   While[i++ < n, {fPrev, fNext} = {fNext, fPrev + fNext}];

fNext] </source>

C/C++

<source lang= "C/C++" line start="2" highlight="4-6">

/** Fibonacci series in C using for loop by Codebind.com

  • /
  1. include <stdio.h>
  2. include <stdlib.h>


int main () {

 int r=0,a=0,n,b=1,i,c;
 char redo;
 do {
   a=0;
   b=1;
   printf("enter the the value of n:");
   scanf("%d", &n);
   if(n>100) {
     printf("enter some lessor value\n");
   }
   else {
     for (i=0;i<=n;i++) {
       c=a+b;
       a=b;
       b=c;
       printf("serial no.%d => ", i+1);
       printf("%d\n",a);
     }
     printf("enter y or Y to continue:");
     scanf("%s", &redo);
     printf("\n");
   }
 }
 while(redo=='y'||redo=='Y');

 return 0;

}

</source>