Small Talk Script

Copy paste the below code in a nodepad file

Dim Msg, Speak
Msg=InputBox("Type view words here","Speak")
Set Speak=CreateObject("sapi.spvoice")
Speak.Speak Msg

Save this file with extension .vbs e.g. example.vbs

Double click on the file and you can see screen this

Type something in the text box and click ok
 and enjoy

Have fun!!!
Keep sharing!!!

C program to create india map

Here is the C program to generate India map

#include‬<stdio.h>
void main()
{
int a,b,c;
for (b=c=10;a="- FIGURE?, UMKC,XYZHello Folks,\
TFy!QJu ROo TNn(ROo)SLq SLq ULo+\
UHs UJq TNn*RPn/QPbEWS_JSWQAIJO^\
NBELPeHBFHT}TnALVlBLOFAkHFOuFETp\
HCStHAUFAgcEAelclcn^r^r\\tZvYxXy\
T|S~Pn SPm SOn TNn ULo0ULo#ULo-W\
Hq!WFs XDt!" [b+++21]; )
{
for( ; a-- > 64 ; )
{
putchar ( ++c=='Z' ? c = c/ 9:33^b&1);
}
}
getch();
}

Remove autorun.inf file from your PenDrive

Many times pen drive gets infected by following files for Windows XP

 Autorun.inf
 folder.exe
 Iexplorer.vbs
 Bha.vbs
 nfo.exe
 New_Folder.exe
 ravmon.exe
 RVHost.exe
 any other files with extension.

just follow this steps :
Step1.:Type cmd in Run
Step2.: Switch to the drive on which pen drive is connected (like C:\> h: enter)
Step3.: type exactly as attrib -s -h *.* /s /d and hit enter (don't forget spaces).

I hope u all like this post

Thank You

Number To Text Javascript

Hi friends here is an example to convert number to text
For example : 12345678
One Crore Twenty Three Lakh Forty Five Thousand Six Hundred and Seventy Eight Only.


HTML Code

<html>
<head>
<title>convert Number to word</title>

</head>

<body>
<input type="text" name="rupees" id="rupees" />

<input type="button" name="sr1" value="Click Here" onClick="Convert()"/>

<div id="wordValue"></div>
</body>
</html>

JAVASCRIPT Code (copy paste this javascript between head tag)


<script>
function Convert() {

var rVal=document.getElementById('rupees').value;
rVal=Math.floor(rVal);
var rup=new String(rVal);
rupRev=rup.split("");
actualNumber=rupRev.reverse();

if(Number(rVal) >=0){

}
else{
alert('Number cannot be converted');
return false;
}
if(Number(rVal)==0){
document.getElementById('wordValue').innerHTML=rup+''+'Rupees Zero Only';
return false;
}
if(actualNumber.length>9){
alert('the Number is too big to covertes');
return false;
}

var numWords=["Zero", " One", " Two", " Three", " Four", " Five", " Six", " Seven", " Eight", " Nine"];
var numPlace=['Ten', ' Eleven', ' Twelve', ' Thirteen', ' Fourteen', ' Fifteen', ' Sixteen', ' Seventeen', ' Eighteen', ' Nineteen'];
var tPlace=['dummy', ' Ten', ' Twenty', ' Thirty', ' Forty', ' Fifty', ' Sixty', ' Seventy', ' Eighty', ' Ninety' ];

var numWordsLength=rupRev.length;
var totalWords="";
var numtoWords=new Array();
var finalWord="";
j=0;
for(i=0; i<numWordsLength; i++){
switch(i)
{
case 0:
if(actualNumber[i]==0 || actualNumber[i+1]==1 ) {
numtoWords[j]='';
}
else {
numtoWords[j]=numWords[actualNumber[i]];
}
numtoWords[j]=numtoWords[j]+' Only';
break;
case 1:
CTen();
break;
case 2:
if(actualNumber[i]==0) {
numtoWords[j]='';
}
else if(actualNumber[i-1]!=0 && actualNumber[i-2]!=0) {
numtoWords[j]=numWords[actualNumber[i]]+' Hundred and';
}
else {
numtoWords[j]=numWords[actualNumber[i]]+' Hundred';
}
break;
case 3:
if(actualNumber[i]==0 || actualNumber[i+1]==1) {
numtoWords[j]='';
}
else {
numtoWords[j]=numWords[actualNumber[i]];
}
if(actualNumber[i+1] != 0 || actualNumber[i] > 0){
numtoWords[j]=numtoWords[j]+" Thousand";
}
break;
case 4:
CTen();
break;
case 5:
if(actualNumber[i]==0 || actualNumber[i+1]==1) {
numtoWords[j]='';
}
else {
numtoWords[j]=numWords[actualNumber[i]];
}
if(actualNumber[i+1] != 0 || actualNumber[i] > 0){
numtoWords[j]=numtoWords[j]+" Lakh";
}
break;
case 6:
CTen();
break;
case 7:
if(actualNumber[i]==0 || actualNumber[i+1]==1 ){
numtoWords[j]='';
}
else {
numtoWords[j]=numWords[actualNumber[i]];
}
numtoWords[j]=numtoWords[j]+" Crore";
break;
case 8:
CTen();
break;
default:
break;
}
j++;
}

function CTen() {
if(actualNumber[i]==0) {
numtoWords[j]='';
}
else if(actualNumber[i]==1) {
numtoWords[j]=numPlace[actualNumber[i-1]];
}
else {
numtoWords[j]=tPlace[actualNumber[i]];
}
}
numtoWords.reverse();
for(i=0; i<numtoWords.length; i++) {
finalWord+=numtoWords[i];
}
document.getElementById('wordValue').innerHTML=rup+'  '+finalWord;
}

</script>

Thank You i hope you liked my post

Credits : http://www.dotnetspider.com

How to download videos from facebook

Step 1 : Click on the video. So you can the watch video.

Step 2 : Copy the URL from the top. For example the url can be like this https://www.facebook.com/photo.php?v=740345752661940&set=vb.123701504326371&type=2&theater

Step 3 : Go to http://www.downvids.net/ here you will find a Text box where you should paste the URL of the facebook video

Step 4 : Click on download. From here you can download any of the facebook video.

Solution to producer consumer problem using Mutual exclusion in unix

#include<stdio.h>
#include "shmlib.h"

main(){
int *lock1,id,sid1,sid2,*prod_quantity;
lock1 = (int *)shared(sizeof(int),&sid1);
init_lock(lock1);
prod_quantity = (int *)shared(sizeof(int),&sid2);
*prod_quantity = 110;
id = create_process(1);
printf("id %d \n",id);
if(id == 0){
lock(lock1);
printf("record deleted by the consumer\n");
*prod_quantity = *prod_qauntity/2;
printf("the decremented values : # %d\n", *prod_quantity);
unlock(lock1);
}
else{
lock(lock1);
printf("record inserted by the producer\n");
*prod_quantity = *prod_quantity*2;
printf("the incremented value : # %d\n",*prod_quantity);
unlock(lock1);
}
join_process(2,id);
printf("After join : the quantity of product after consumer access : %d\n",*prod_quantity);
free_shm(sid1);
free_shm(sid2);
}

Demonstrate the shared memory model of programming in Parallel Processing

#include<stdio.h>
#include "shmlib.h"

int main(){
in final_sum, *sum0, sum1, id, id1, id2;
sum0 = (int*)shared(sizeof(int),&id1);
sum1 = (int*)shared(sizeof(int),&id2);
id = create_process(1);
if(id == 0){
*sum0 = 10+15;
printf("\n Sum0 : %d",*sum0);
}
if(id == 1){
*sum1 = 6 + 7;
printf("\n Sum1 : %d", *sum1);
}
join_process(2,id);
final_sum = *sum + *sum1;
printf("\n Final Result : %d",final_sum);
printf("\n");
free_shm(id1);
free_shm(id2);
return 0;
}

Demonstrate the concept of Mutual Exclusion in Parallel Processing

For this program you must have some knowledge of mutual exclusion and pointers

#include<stdio.h>
#include "shmlib.h"

main(){
int *lock1,id, sid1, sid2, *i, j;

//this allocates memory of int size and this is a shared memory which is accessed from sd1
lock1 = (int*)shared(sizeof(int),&sid1);

//initializing lock
init_lock(lock1);

//this allocates memory of int size and this is a shared memory which is accessed from sd2
i=(int*)shared(sizeof(int),&sid2);

*i=110;
j=110;

printf("before fork : %d %d\n",*i,j);
id=create_process(2);
lock(lock1);

*i=id;
j=id*2;

printf("After Fork : %d %d\n", i*,j);

//lock released
unlock(lock1);

join_process(3,id);
printf("After Join : %d %d\n",*i,j);

//memory released
free_shm(sid1);
free_shm(sid2);
}

Creation and Destruction of Process In Unix

#include<stdio.h>
#include "shmlib.h"


main(){

int id, n;
//id is used for numbering each process, n is used for user to enter total number of processes

printf("This program creates user entered number minus one child processes,");
printf("\n Assign Task to each child process and once the the processing is complete, all child process are killed");
printf("\n Enter the nmber of processes : ");
// here user enter number of processes

scanf("%d",&n);
// creates process
id = create_process(n);

//conditions to check parallel execution by child if the id is greater than 0
id(id > 0){
printf("\n Parallel Execution");
printf("\n O/P from child %d My Id is : %d \n",id,id);
}
//condition to check for parent process
else if(id == 0){
printf("\n O/P from Parent Process : My id = %d",id);
}
join_process(n,id)
printf("\n Sequential Execution");
printf("Finished");
}

Crossover

Write a program in Lisp to demonstrate the crossover genetic operator.

 (Enter population of binary strings. Perform crossover based on a random crossing site value. Consider fitness value as the number of repetitions of specified bit in the string. Perform the evolution for a specified number generation).


CODE:

(defun Cross(List1 List2)
(setq Cnt 0)
(setq newList1 '())
(setq newList2 '())
(setq cp (random (length List1)))
(print "CrossOver Point")
(prin1 cp)
(loop
                                (when (equal (first List1) nil)(return))
                                (if (<= cp Cnt)
                                                (block blkOne
                                                                (setq newList1 (cons (first List2) newList1))
                                                                (setq newList2 (cons (first List1) newList2))
                                                )
                                                (block blkTwo
                                                                (setq newList1 (cons (first List1) newList1))
                                                                (setq newList2 (cons (first List2) newList2))
                                                )
                                )
                                (incf Cnt)
                                (setq List1 (rest List1))
                                (setq List2 (rest List2))
                )
                (setq List1 (append newList1 newList2))
)
(defun mainCross (listOne listTwo Gen)

(setq genCntr 0)
(setq tempList '())
                (loop
                                (when(equal genCntr Gen)(return))
                    (setq posCntr 0)(setq tempList '())
                                (setq tempList (Cross listOne listTwo))
                    (setq lenTempList (length templist))
                                (setq listOne '())
                    (setq listTwo '())
    (loop
                                  (when (equal (first tempList) nil)(return))
               
                                                (if (< posCntr (/ lenTempList 2))
                                                                (setq listOne (cons (first tempList) listOne))
                                        (setq listTwo (cons (first tempList) listTwo))
                                                )
                                                (incf posCntr)
                                                (setq tempList (rest tempList))
    )
    (incf genCntr)
    (print "Result of Crossing")   
    (print listOne)
    (print listTwo)  ))

(mainCross '(1 2 3 4) '(5 6 7 8) 3)
OUTPUT:

"CrossOver Point" 0
"Result of Crossing"
(5 6 7 8)
(1 2 3 4)
"CrossOver Point" 0
"Result of Crossing"
(1 2 3 4)
(5 6 7 8)
"CrossOver Point" 3
"Result of Crossing"
(1 2 3 8)
(5 6 7 4)
NIL

Mutation

Write a program in Lisp to demonstrate the genetic operator mutation.

(Enter a population of binary strings. Perform mutation based on a random mutation point. Consider fitness value as the number of repetitions of a specified bit (say 1) in the string. Perform the evolution for a specified number generation.)


CODE:

(defun Muta(List)
(setq Cnt 0)
(setq newList '())
(setq mp (random (length List)))

(print "Mutation Point")
(prin1 mp)

                (loop
                                (when (equal (first List) nil) (return))
                                (if (equal mp Cnt)
                                                (if(equal (first List) 0)
                                                                (setq newList (cons '1 newList))
                                                                (setq newList (cons '0 newList))
                                                )
                               
                                                (setq newList (cons (first List) newList))
                                )
                               
                                (incf Cnt)
                                (setq List (rest List))
                )
               
                (setq List (reverse newList))
        (setq newList '())
                (print List)
)

(defun mainMuta (List1 List2 Gen)
(setq FVList1 0)
(setq FVList2 0)
(setq GenCntList1 0)
(setq GenCntList2 0)
(setq dplList '())

                (loop
                                (when (equal GenCntList1 Gen) (return))
                                (when (equal GenCntList2 Gen) (return))
                               
                                (setq FVList1 0)
                                (setq dplList List1)
                                (loop
                                                (when (equal (first List1) nil) (return))
                                                (if(equal (first List1) 1)(incf FVList1))
                                                (setq List1 (rest List1))
                                )
                                (setq List1 dplList)
                               
                                (setq FVList2 0)
                                (setq dplList List2)
                                (loop
                                                (when (equal (first List2) nil) (return))
                                                (if(equal (first List2) 1) (incf FVList2))
                                                (setq List2 (rest List2))
                                )
                                (setq List2 dplList)

                                (if (> FVList1 FVList2)
                                                (block blkOne
                                                                (incf GenCntList1)
                                                                (setq dplList List1)
                                                                (setq List1 (Muta List1))
                                                                (print "List1:-")
                                                                (prin1 List1)
                                                                (prin1 "List1 Generation Count:-")
                                                                (prin1 GenCntList1)
                                                )
                                                (block blkTwo
                                                                (incf GenCntList2)
                                                                (setq dplList List2)
                                                                (setq List2 (muta List2))
                                                                (print "List2:-")
                                                                (prin1 List2)
                                                                (prin1 "List2 Generation Count:-")
                                                                (prin1 GenCntList2)
                                                )
                                )
                )
)


(mainMuta '(1 2 3 4) '(5 6 7 8) 3)

OUTPUT:

"Mutation Point" 0
(0 2 3 4)
"List1:-" (0 2 3 4)"List1 Generation Count:-"1
"Mutation Point" 3
(5 6 7 0)
"List2:-" (5 6 7 0)"List2 Generation Count:-"1
"Mutation Point" 1
(5 0 7 0)
"List2:-" (5 0 7 0)"List2 Generation Count:-"2
"Mutation Point" 1
(5 1 7 0)
"List2:-" (5 1 7 0)"List2 Generation Count:-"3
NIL

Roulette Wheel

Write a program in Lisp to perform roulette wheel selection. (Enter a population of binary strings. Consider fitness value as the number of repetitions of a specified bit (say 1) in the string.)


CODE:

(defun strStg (strWord)
(setq stgCnt 0)
(setq lenCnt 0)
                (loop
                                (when (equal lenCnt (length strWord)) (return stgCnt))
                                (if (equal (char "1" 0) (char strWord lenCnt)) (incf stgCnt))
                                (incf lenCnt)
                )
)

(strStg "10001")

(defun RW (strOne strTwo strThree strFour strFive)
(setq Cnt 0)
(setq stgList '())

                (setq strOneStg (strStg strOne))
                (setq strTwoStg (strStg strTwo))
                (setq strThreeStg (strStg strThree))
                (setq strFourStg (strStg strFour))
                (setq strFiveStg (strStg strFive))

                (setq stgList (push strOneStg stgList))
                (setq stgList (push (+ strOneStg strTwoStg) stgList))       
                (setq stgList (push (+ strOneStg strTwoStg strThreeStg) stgList))
                (setq stgList (push (+ strOneStg strTwoStg strThreeStg strFourStg) stgList))
                (setq stgList (push (+ strOneStg strTwoStg strThreeStg strFourStg strFiveStg) stgList))

                (setq strSel (Mod (random 1000) (first stgList)))
                (print strSel)

                (loop
                                (when (equal (first stgList) nil) (return))
                                (if (>= strSel (first stgList))
                                                (block blkIf
                                                                (if(equal Cnt 0)(return strOne))
                                                                (if(equal Cnt 1)(return strTwo))
                                                                (if(equal Cnt 2)(return strThree))
                                                                (if(equal Cnt 3)(return strFour))
                                                                (if(equal Cnt 4)(return strFive))
                                                )
                                )
                                (setq stgList (rest stgList))
                                (incf Cnt)
                )
)

(RW "100110" "100101" "001010" "010101" "100001")

OUTPUT:
---- Done ----

1

---- Done ----

7
"010101"

A fuzzy system is a structured Numerical estimator in LISP example Inverted Pendulum

Write a program in Lisp to demonstrate that a fuzzy system is a structured
Numerical estimator-using example of controlling an inverted pendulum.
(Enter two strings for angle of pendulum θ and angular velocity Δθ.

Convert them into strings of fuzzy using five fuzzy set values NM(Negative medium), NS (Negative Small), ZE(Zero), PS (Positive Small) and PM ( Positive Medium). Apply FAM rules to find the output values v,the current to the motor control of the pendulum to each input set of (θ,Δθ). Create a string of fuzzy output values of the current.)

(defun FAM (angPen anguVel)
                (cond
                                ((equal angPen "NM")
                                                                (cond
                                                                                ((equal anguVel "NM") nil)
                                                                                ((equal anguVel "NS") nil)
                                                                                ((equal anguVel "ZE") (print "PM"))
                                                                                ((equal anguVel "PS") nil)
                                                                                ((equal anguVel "PM") nil)
                                                                )
                                )
                                ((equal angPen "NS")
                                                                (cond
                                                                                ((equal anguVel "NM") nil)
                                                                                ((equal anguVel "NS") nil)
                                                                                ((equal anguVel "ZE") (print "PS"))
                                                                                ((equal anguVel "PS") nil)
                                                                                ((equal anguVel "PM") nil)
                                                                )
                                )
                                ((equal angPen "ZE")
                                                                (cond
                                                                                ((equal anguVel "NM") (print "PM"))
                                                                                ((equal anguVel "NS") (print "PS"))
                                                                                ((equal anguVel "ZE") (print "ZE"))
                                                                                ((equal anguVel "PS") (print "NS"))
                                                                                ((equal anguVel "PM") (print "NM"))
                                                                )
                                )
                                ((equal angPen "PS")
                                                                (cond
                                                                                ((equal anguVel "NM") nil)
                                                                                ((equal anguVel "NS") nil)
                                                                                ((equal anguVel "ZE") (print "NS"))
                                                                                ((equal anguVel "PS") nil)
                                                                                ((equal anguVel "PM") nil)
                                                                )
                                )
                                ((equal angPen "PM")
                                                                (cond
                                                                                ((equal anguVel "NM") nil)
                                                                                ((equal anguVel "NS") nil)
                                                                                ((equal anguVel "ZE") (print "NM"))
                                                                                ((equal anguVel "PS") nil)
                                                                                ((equal anguVel "PM") nil)
                                                                )
                                )
                )
)

(FAM "NM" "ZE")

OUTPUT:
---- Done ----
FAM
---- Done ----
"PM"