Posts

Showing posts from September, 2018

Ruby Word and Letter Counter

Image
Ruby Word and Letter Counter This simple Program will accept a string and return the total number of words and show the number of occurrences for each letter. Ruby #Enter a string to see word & letter counts puts "Enter your text:" text = gets.chomp puts  "#{text}" word_count = text.split(' ').count puts "Word count is #{word_count} \nLetter Frequency is:" text.downcase! freqs = {} freqs.default = 0 text.each_char { |char| freqs[char] += 1} ("a".."z").each {|x| puts "#{x} : #{freqs[x]}" } puts "Thank You" Click here to run this code More Free Code Examples: Javascript Substitution Cipher Javascript Easy Battleship Game Hello World in 10 Programming Languages Try these Fun Games by Bobbie: Travel Blast Game New York Play and Learn Russian Battlestarship Game Take a look at these Groovy Codes: ...

Java Program to Create a Diamond

Image
Create a Diamond Shape using this Java Code Java import java.util.Scanner;  public class Diamond {      public static void main(String[] args) {          int n, i, p,  space = 1;          Scanner s=new Scanner(System.in);          System.out.println("Enter number of rows: ");           n=s.nextInt();          space = n - 1;            for (p = 1; p<=n; p++) {           for (i = 1; i<=space; i++)           System.out.print(" ");           space--;          for (i = 1; i<= 2*p-1; i++)           System.out.print("*");   System.out.print("\n");}                 ...

Waves Example Three.js

Image
This is a really fun and exciting code to demonstrate the awesome abilities of Three.js * Featured Code Created By  Rull Deef HTML <!DOCTYPE html> <html> <head>   <title>Waves example based on three.js lib</title>   <script src='https://cdnjs.cloudflare.com/ajax/libs/three.js/r83/three.min.js'>   </script> </head> <body>   <span>change z component of each vertex<br/>     to see wave animation<br/>     x, y, z - current components<br/>     t - time value (very big, use in trig. funcs<br/>       to animate waves)<br/>     pi, e - constants<br/>     sqrt, sin, cos, abs, log - std. functions<br/>     d - distance from center (=sqrt(x*x+y*y))   </span>      <button onclick...

Java Fibonacci Sequence

Image
This Easy Java Code will produce a set Number of terms of the Fibonacci Sequence Java public class Fibonacci { public static void main(String[] args) { int n = 30, t1 = 0, t2 = 1; System.out.print("Fibonacci first " + n + " terms: "); for (int i = 1; i <= n; ++i){  System.out.print(t1 + " + ");      int sum = t1 + t2; t1 = t2; t2 = sum; } } } Click here to run this code More Free Code Examples: Java Code to Reverse a String Java Current Time and Date Program Java Random Numbers

CSS Background 1

Image
Pure CSS Background  CSS { background-color: #fff;     background-size: 60px 60px;     background-position: 0 0, 30px 30px;     background-image: -webkit-linear-gradient(45deg, black 25%, transparent 25%, transparent 75%, black 75%, black), -webkit-linear-gradient(45deg, black 25%, transparent 25%, transparent 75%, black 75%, black);     background-image: -moz-linear-gradient(45deg, black 25%, transparent 25%, transparent 75%, black 75%, black), -moz-linear-gradient(45deg, black 25%, transparent 25%, transparent 75%, black 75%, black);     background-image: -ms-linear-gradient(45deg, black 25%, transparent 25%, transparent 75%, black 75%, black), -ms-linear-gradient(45deg, black 25%, transparent 25%, transparent 75%, black 75%, black);     background-image: -o-linear-gradient(45deg, black 25%, transparent 25%, transparent 75%, black 75%, black), -o-linear-gradient(45deg,...

Java Random Numbers

Image
This simple Program will output Random Numbers using Java Java import java.util.*;  class RandomNumbers {  public static void main(String[] args) {  int counter;  Random nums = new Random();  System.out.println("Random Numbers:"); for (counter = 1; counter <= 5; counter++) {    System.out.println(nums.nextInt(100)); } } } Click here to see this code run More Free Code Examples: Java Code to Reverse a String Java Current Time and Date Program Javascript Easy Battleship Game

C++ Multiply 2 Overflow Numbers

Image
This program will allow you to input 2 large numbers and multiple them using C++    *Featured code submitted and Created by  🇻🇳GNAOH🇻🇳 . C++ #include <iostream> #include <cstring> using namespace std; char n1[100],n2[100];int r[200]; int main() {     int n;     cin>>n1>>n2;cout<<"  "<<n1<<" * "<<n2<<endl<<"= ";     strrev(n1);strrev(n2);     for(int i=0;i<strlen(n2);i++)     {         for(int j=0;j<strlen(n1);j++)         {             n=(n1[j]-48)*(n2[i]-48);             r[i+j]+=n;             if(r[i+j]>=10)             {                 r[i+j+1]+=r[i+j]/10;         ...

Python Word Repeater

Image
This code will take a string you enter and repeat it for the number of times you specify using Python.      * Featured code submitted and Created by  Facu . Python def repeater(word, cant):  for i in range(cant):   print(word) try:  a = input()  b = int(input())  repeater(a, b) except (ValueError):  print("An error ocurred:")  print("\nThe second value must be a whole number!") except (EOFError):  print("An error ocurred:")  print("\nYou must enter a number in the second line!") Click here to try this code More Free Code Examples: Python Code to Reverse a String Hello World in 10 Programming Languages 8 Codes to Find Versions

3d Dice Roll Animation

Image
This Great Code Creates a Fun Interactive 3d Cube     *Featured Code submitted and Created By  Amir Ahmad . HTML with CSS <!doctype html> <html lang="en"> <head>     <meta charset="UTF-8">     <title>3dDice</title>     <style> body {     background-color:#0dd;     }     #view{     width:200px;     height:200px;     margin:100px;     perspective:600px;     }     #dice{     width:200px;     height:200px;     position:relative;     transform-style:preserve-3d;     transition: transform 1s;     }     #btnFront:checked ~ #view>#dice{     transform:rotateY(360deg) !important;     }     #btnRight:checked ~ #view>#dice{ ...

C++ Check for Palindrome

Image
This Code takes your input reverses it and decides if it's a Palindrome. * Featured post submitted and created by  Padmanabhan . C++ #include <iostream> #include<string.h> using namespace std; int main() {     char a[50],b[50];     int j=0,i;     //Enter a word     cin>>a;     i=strlen(a);     for(;i>0;i--)     {         b[j]=a[i-1];         j++;     }     b[j]='\0';     cout<<"\nThe reverse of the string:\n"<<b<<endl;     if(strcmp(a,b)==0)     cout<<"\nThe given word is PALINDROME";     else     cout<<"\nThe given word is not PALINDROME";     return 0; } Click here to run this code More Free Code Examples: C++ Code to Reverse a Number C++ Odd o...

PHP Current Calender

Image
This Code Creates this Months Current Calendar using PHP PHP <?php     echo "<HTML>\n" . " <HEAD>\n" . " <STYLE>\n" . "BODY, TD, TH\n" . "{\n" . " font-family: Verdana;\n" . " font-size: 15pt;\n" . "}\n" . " </style>\n" . " </head>\n" . " <BODY>\n";      $month = "";      if ($month == "" || $year == "") { $this_month = date("n"); $month_name = date("F"); $this_year = date("Y"); }             else { $this_month = date("n", mktime(0, 0, 0, $month, 1, $year)); $month_name = date("F", mktime(0, 0, 0, $month, 1, $year)); $this_year = date("Y", mktime(0, 0, 0, $month, 1, $year)); }  $last_month = $this_month - 1; $next_month = $this_month + 1;              if ($last_month == 12) $last_year = $this_year - 1; else $last...

C++ String Rotation

Image
This program accepts a string argument and returns an array of strings, which are shifted versions of the argument string. * Featured post submitted and created by  Padmanabhan .  C++ #include <iostream> using namespace std; void StringRotator(string s, int len); int main() {     string s;          //Getting Input              cin>>s;     if(s. length()!=0)     {         cout<<"[";         StringRotator(s,s.length());         cout<<"]";     }     else         cout<<"Sorry! No input is given";     return 0; } void StringRotator(string s,int len) {         static int i=0;     cout<<"\"";     for(int j=i;j<...

3d Glowing Text HTML & CSS

Image
Create Awesome Glowing 3d Text with this Fun HTML & CSS Code *Featured Code submitted and Created By  Amir Ahmad . HTML <!doctype html> <html lang="en"> <head>     <meta charset="UTF-8">     <title>3d Text</title>     <link rel="stylesheet" href="styles.css">      </head> <body>     <div id="view">         <h1>LOVE FOR ALL</h1>         <h1>LOVE FOR ALL</h1>         <h1>LOVE FOR ALL</h1>         <h1>LOVE FOR ALL</h1>         <h1>LOVE FOR ALL</h1>         <h1>LOVE FOR ALL</h1>         <h1>LOVE FOR ALL</h1>         <h1>LOVE FOR ALL</h1>       ...