Sunday, 12 July 2020

Simple Calculator in HTML

  • Start notepad.exe
  • Type:
<!doctype HTML>
<html>
<head>
<title>Calculator</title>
<script type="text/javascript">
function showTheAdd(){
 var abc = document.getElementById('n1').value;
 var def = document.getElementById('n2').value;
 document.getElementById('data').innerHTML=parseInt(abc)+ parseInt(def);
}
function showTheSubs(){
 var abc = document.getElementById('n1').value;
 var def = document.getElementById('n2').value;
 document.getElementById('data').innerHTML=parseInt(abc)- parseInt(def);
}
function showTheMult(){
 var abc = document.getElementById('n1').value;
 var def = document.getElementById('n2').value;
 document.getElementById('data').innerHTML=parseInt(abc)* parseInt(def);
}
function showTheDiv(){
 var abc = document.getElementById('n1').value;
 var def = document.getElementById('n2').value;
 document.getElementById('data').innerHTML=parseInt(abc)/ parseInt(def);
}
</script>
</head>
<body bgcolor="red" topmargin="200">
<form id="frm" autocomplete="off">
<table align="center" border="1">
<tr><td colspan="4">First Number&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="number" id="n1" /></td></tr>
<tr><td colspan="4">Second Number&nbsp;&nbsp;&nbsp;<input type="number" id="n2" /></td></tr>
<tr>
    <td align="center"><button type="button" onClick="javascript:return showTheAdd();">Add</button></td>
    <td align="center"><button type="button" onClick="javascript:return showTheSubs();">Substract</button></td>
    <td align="center"><button type="button" onClick="javascript:return showTheMult();">Multiply</button></td>
    <td align="center"><button type="button" onClick="javascript:return showTheDiv();">Divide</button></td>
</tr>
<tr><td align="center" colspan="4"><button type="reset">Reset</button></td></tr>
<tr><td colspan="4" align="center"><label id="data"></label></td></tr>
</table>
</form>
</body>
</html>
  • Save this file as calc.cmd
  • This can be used as a simple calculator to add, substract, multiply and divide.

Thursday, 2 July 2020

Use CMD as Calculator!

You can use CMD as your own Calculator! (It doesn't allow desimals though)
  • Start cmd.exe on your system
  • Type :
    set /a n=<type your equation here> 
  • Press enter
  • You will see your answer below the question.
  • For example, if you type set /a n=(5+1)/3 then you will see 2 given below

Prime Checker Program in CMD

This program is to make a program that checks whether a number is prime or not
  • Start Notepad or Notepad++ on your system
  • Type this:
  • @echo off
    :x
    set /p num=Enter number: 
    set /a n=%num%
    set /a s=1
    :a
    set /a s=%s%+1
    if %s% equ %n% goto c
    set /a a=%n% %% %s%
    if %a% equ 0 goto b
    goto a
    :b 
    echo Composite  
    goto x
    :c 
    echo Prime  
    goto x
  • Save it as prime.cmd on desktop and double click the file to start it

List of primes in CMD

This program aims to make a program that will give a list of prime numbers (slowly...) from 2 to infinity.
  • Start notepad.exe on your system or Notepad++
  • Type the following: 
@echo off
echo 2 
set /a n=1
:x 
set /a n=%n%+2
set /a s=1
:a
set /a s=%s%+1
if %s% equ %n% goto c
set /a a=%n% %% %s%
if %a% equ 0 goto b
goto a
:b   
goto x
:c
echo %n% 
goto x

  • Save this as primelist.cmd at desktop
  • Double-click on the file to start the program

Algorithmic Pixel Art: The Beauty of Aliasing

Discussed  here More images in  Google drive Some outputs: Forward to anyone who says aliasing is ugly.