Friday, July 20, 2012

Generate dick number in javascript.

 Code

<html>
<head>
<script type="text/javascript">
function rnd(){
document.asim.khan.value=Math.floor((Math.random()*6)+1);
}
</script>
</head>
<body>
<form name="asim">
<center>
<input type="text" name="khan"/>
<input type="button" value="click" onclick="rnd()"/>
</centr>
</form>
</body>
</html>

 

view







simple calculator in javascript.

code


<html>
<head>
<script type="text/javascript">
function solve(){
document.asim.val.value=eval(document.asim.val.value);
}
</script>
</head>
<body><center>
<form name="asim">
<table border="4">
<tr><td colspan="4"><input type="text" name="val" size="45"></td></tr>
<tr><td><input type="button" value="1" style="height: 25px; width: 70px" onclick="(document.asim.val.value) +='1'"/></td>
<td><input type="button" value="2" style="height: 25px; width: 70px" onclick="(document.asim.val.value) +='2'"/></td>
<td><input type="button" value="3" style="height: 25px; width: 70px" onclick="(document.asim.val.value) +='3'"/></td>
<td><input type="button" value="4" style="height: 25px; width: 70px" onclick="(document.asim.val.value) +='4'"/></td></tr>
<tr><td><input type="button" value="5" style="height: 25px; width: 70px" onclick="(document.asim.val.value) +='5'"/></td>
<td><input type="button" value="6" style="height: 25px; width: 70px" onclick="(document.asim.val.value) +='6'"/></td>
<td><input type="button" value="7" style="height: 25px; width: 70px" onclick="(document.asim.val.value) +='7'"/></td>
<td><input type="button" value="8" style="height: 25px; width: 70px" onclick="(document.asim.val.value) +='8'"/></td></tr>
<tr><td><input type="button" value="9" style="height: 25px; width: 70px" onclick="(document.asim.val.value) +='9'"/></td>
<td><input type="button" value="0" style="height: 25px; width: 70px" onclick="(document.asim.val.value) +='0'"/></td>
<td><input type="button" value="+" style="height: 25px; width: 70px" onclick="(document.asim.val.value) +='+'"/></td>
<td><input type="button" value="-" style="height: 25px; width: 70px" onclick="(document.asim.val.value) +='-'"/></td><tr>
<tr><td><input type="button" value="x" style="height: 25px; width: 70px" onclick="(document.asim.val.value) +='*'"/></td>
<td><input type="button" value="/" style="height: 25px; width: 70px" onclick="(document.asim.val.value) +='/'"/></td>
<td><input type="button" value="Mod" style="height: 25px; width: 70px" onclick="(document.asim.val.value) +='%'"/></td>
<td><input type="button" value="=" style="height: 25px; width: 70px" onclick="solve()" /></td></tr>
</table>
</center>
</body>
</html>

view







scientific calculator in javascript.

                                     code  

<html>
<head>
<script type="text/javascript">
function solve(){
document.asim.num.value=eval(document.asim.num.value);
}
function sin(){
document.asim.num.value=Math.sin(document.asim.num.value);
}
function cos(){
document.asim.num.value=Math.cos(document.asim.num.value);
}
function tan(){
document.asim.num.value=Math.tan(document.asim.num.value);
}
function sini(){
document.asim.num.value=Math.asin(document.asim.num.value);
}
function cosi(){
document.asim.num.value=Math.acos(document.asim.num.value);
}
function tani(){
document.asim.num.value=Math.atan(document.asim.num.value);
}
function sq(){
document.asim.num.value=eval(document.asim.num.value)*eval(document.asim.num.value);
}
function cub(){
document.asim.num.value=eval(document.asim.num.value)*eval(document.asim.num.value)*eval(document.asim.num.value);
}
function exp(){
document.asim.num.value=Math.exp(document.asim.num.value);
}
function log(){
document.asim.num.value=Math.log(document.asim.num.value);
}
function inv(){
document.asim.num.value=1/(document.asim.num.value);
}
function pi(){
document.asim.num.value=22/7;
}
function sqrt(){
document.asim.num.value=Math.sqrt(document.asim.num.value);
}
</script>
</head>
<body>
<form name="asim"><center>
<table border="2">
<tr><td colspan="4"><input type="text" name="num" size="45"><br></td></tr>
<tr>
<td><input type="button" value="1" style="height: 25px; width: 70px" onclick="(document.asim.num.value) +='1'"/></td>
<td><input type="button" value="2" style="height: 25px; width: 70px" onclick="(document.asim.num.value) +='2'"/></td>
<td><input type="button" value="3" style="height: 25px; width: 70px" onclick="(document.asim.num.value) +='3'"/></td>
<td><input type="button" value="4" style="height: 25px; width: 70px" onclick="(document.asim.num.value) +='4'"/></td></tr>
<tr><td><input type="button" value="5" style="height: 25px; width: 70px" onclick="(document.asim.num.value) +='5'"/></td>
<td><input type="button" value="6" style="height: 25px; width: 70px" onclick="(document.asim.num.value) +='6'"/></td>
<td><input type="button" value="7" style="height: 25px; width: 70px" onclick="(document.asim.num.value) +='7'"/></td>
<td><input type="button" value="8" style="height: 25px; width: 70px" onclick="(document.asim.num.value) +='8'"/></td></tr>
<tr><td><input type="button" value="9" style="height: 25px; width: 70px" onclick="(document.asim.num.value) +='9'"/></td>
<td><input type="button" value="0" style="height: 25px; width: 70px" onclick="(document.asim.num.value) +='0'"/></td>
<td><input type="button" value="." style="height: 25px; width: 70px" onclick="(document.asim.num.value) +='.'"/></td>
<td><input type="button" value="+" style="height: 25px; width: 70px" onclick="(document.asim.num.value) +='+'"/></td></tr>
<tr><td><input type="button" value="-" style="height: 25px; width: 70px" onclick="(document.asim.num.value) +='-'"/></td>
<td><input type="button" value="*" style="height: 25px; width: 70px" onclick="(document.asim.num.value) +='*'"/></td>
<td><input type="button" value="/" style="height: 25px; width: 70px" onclick="(document.asim.num.value) +='/'"/></td>
<td><input type="button" value="Mod" style="height: 25px; width: 70px" onclick="(document.asim.num.value) +='%'"/></td></tr>
<tr><td><input type="button" value="sqre" style="height: 25px; width: 70px" onclick="sq()"/></td>
<td><input type="button" value="cube" style="height: 25px; width: 70px" onclick="cub()"/></td>
<td><input type="button" value="sqrt" style="height: 25px; width: 70px" onclick="sqrt()"/></td>
<td><input type="button" value="pi" style="height: 25px; width: 70px" onclick="pi()"/></td></tr>
<tr><td><input type="button" value="log" style="height: 25px; width: 70px" onclick="log()"/></td>
<td><input type="button" value="sin" style="height: 25px; width: 70px" onclick="sin()"/></td> 
<td><input type="button" value="cos" style="height: 25px; width: 70px" onclick="cos()"/></td>
<td><input type="button" value="tan" style="height: 25px; width: 70px" onclick="tan()"/></td></tr>
<tr><td><input type="button" value="exp" style="height: 25px; width: 70px" onclick="exp()"/></td>
<td><input type="button" value="asin" style="height: 25px; width: 70px" onclick="sini()"/></td>
<td><input type="button" value="acos" style="height: 25px; width: 70px" onclick="cosi()"/></td>
<td><input type="button" value="atan" style="height: 25px; width: 70px" onclick="tani()"/></td></tr>
<tr><td><input type="button" value="1/x" style="height: 25px; width: 70px" onclick="inv()"/></td>
<td><input type="button" value="C" style="height: 25px; width: 70px" onclick="(document.asim.num.value)=0"/></td>
<td colspan="2"><input type="button" value="=" style="height: 25px; width: 145px" onclick="solve()"/></td><tr>
</table>
</center>
</form>
</body>
</html>

              

                                    view







Tuesday, July 17, 2012

Cheaking prime number code in C++


#include<iostream.h>
 #include<math.h>
 void main()
 {
 int num,count=2;
 double sqnum;
 cout<<"enter the number you want to check\n";
 cin>>num;
 sqnum=sqrt(num);
 while(count<=sqnum)
 {
 if(num%count==0)
 {
 cout<<"the number you enter is not a prime number\n";
 break;
 }
 else
 {
 count++;
 }
 }
 if(num%count!=0)
 {
 cout<<"the number is a prime number\n";
 }
 }

Saturday, July 14, 2012

simple calculator code in javascript.

                                              code 

<html>  
      
    <head>  
      
    <title>Simple Javascript Calculator - Basic Arithmetic Operations</title>  
      
 
      
    <script language="javascript" type="text/javascript">  
    function multiply(){  
    a=Number(document.calculator.number1.value);  
    b=Number(document.calculator.number2.value);  
    c=a*b;  
    document.calculator.total.value=c;  
    }  
    </script>  
      
    <script language="javascript" type="text/javascript">  
    function addition(){  
    a=Number(document.calculator.number1.value);  
    b=Number(document.calculator.number2.value);  
    c=a+b;  
    document.calculator.total.value=c;  
    }  
    </script>  
      
    <script language="javascript" type="text/javascript">  
    function subtraction(){  
    a=Number(document.calculator.number1.value);  
    b=Number(document.calculator.number2.value);  
    c=a-b;  
    document.calculator.total.value=c;  
    }  
    </script>  
      
    <script language="javascript" type="text/javascript">  
    function division(){  
    a=Number(document.calculator.number1.value);  
    b=Number(document.calculator.number2.value);  
    c=a/b;  
    document.calculator.total.value=c;  
    }  
    </script>  
      
    <script language="javascript" type="text/javascript">  
    function modulus(){  
    a=Number(document.calculator.number1.value);  
    b=Number(document.calculator.number2.value);  
    c=a%b;  
    document.calculator.total.value=c;  
    }  
    </script>  
      
    </head>  
      
    <body>  
      
    
    <form name="calculator">  
      
 
    Number 1: <input type="text" name="number1">   
       
      

    Number 2: <input type="text" name="number2">   
      
      
 
    Get Result: <input type="text" name="total">   
      
      
      
    <input type="button" value="ADD" onclick="javascript:addition();">  
    <input type="button" value="SUB" onclick="javascript:subtraction();">  
    <input type="button" value="MUL" onclick="javascript:multiply();">  
    <input type="button" value="DIV" onclick="javascript:division();">  
    <input type="button" value="MOD" onclick="javascript:modulus();">  
      
    </form>  
      
    </body>  
    </html>  

                                               view

Simple Javascript Calculator - Basic Arithmetic Operations
      Number 1:

      Number 2:

      Get Result:
   

factoria code in c++

#include<iostream.h>
void main()
{
    int num,fact=1;
    cout<<"Enter the number .\n";
    cin>>num;
    while(num>0)
    {
        fact=fact*num;
        num--;
    }
    cout<<"The factoria of number is "<<fact<<" .\n";
}

Friday, July 6, 2012

java script scientific calculator