Saturday, 20 October 2012

Accept n numbers through one program send it to the server program check their for prime numbers send only the prime numbers to client-Java Socket program

tcpserver1.java import java.io.*; import java.net.*; class tcpserver1 { public static void main(String args[])throws Exception { ServerSocket ss = new ServerSocket(6856); Socket cs=ss.accept(); BufferedReader br = new BufferedReader(new InputStreamReader(cs.getInputStream())); PrintStream ps = new PrintStream(cs.getOutputStream()); int[] a=new int[15]; int[] b= new int [15]; int k=0,n,i,j,f=0; n=Integer.parseInt(br.readLine()); for(i=0;i<n;i++) a[i]=Integer.parseInt(br.readLine()); for(i=0;i<n;i++) { for(j=2;j<a[i];j++) { if(a[i]%j==0) { f=1; break; } } if(f==0) { if(a[i]!=1) { b[k]=a[i]; k++; } } f=0; } ps.println(k); for(i=0;i<k;i++) ps.println(b[i]); } } tcpclient1.java import...

Communication between two unrelated process using messege queue

MSGQ1.c  #include<stdio.h>#include<sys/msg.h>#include<string.h>#include<stdlib.h>struct msgbuf {long mtype;char mtext[30];}ptr;int main(){int i=0;int id=msgget(52,0666|IPC_CREAT);if(id>=0)printf("Msg Q created sucessfully\n");elseprintf("Not created\n");printf("Enter the msg type:\n");scanf("%ld",&(ptr.mtype));printf("Enter the msg\n");scanf("%s",ptr.mtext);int p=msgsnd(id,&ptr,(sizeof(ptr.mtext)),0);if(p>=0)printf("Msg send sucessfully\n");elseprintf("Msg not send\n");} MSGQ2.C #include<stdio.h>#include<sys/msg.h>struct...

Sunday, 7 October 2012

Udp Client-Server Communication using java

UDP Client import java.io.*;import java.net.*;class udpclient {    public static void main(String args[])throws Exception    {                DatagramSocket cs = new DatagramSocket(2568);        InetAddress ip = InetAddress.getByName("localhost");        byte[] sD = new byte[1024];        byte[] rD = new byte[1024]; String sen;       ...

Tcp client server communication using Java

TCP Client import java.io.*;import java.net.*; class tcpclient {    public static void main(String args[])throws Exception    {        Socket s = new Socket("localhost",6700);        BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));        PrintStream ps2 = new PrintStream(s.getOutputStream());        BufferedReader kb = new BufferedReader(new...

Two unrelated programs uses shared memory

First program #include<stdio.h>#include<sys/shm.h>#include<string.h>int main(){int id=shmget(17,50,0666|IPC_CREAT);if(id>=0){printf("\nShared memory created with id:%d\n",id);}char *adr=shmat(id,NULL,0);if(adr>=0)printf("Memory attached\n");printf("Enter a string\n");char str[10];scanf("%s",str);strncpy(adr,str,sizeof(str));} Second program #include<stdio.h>#include<sys/shm.h>#include<string.h>int main(){int id=shmget(17,0,0666|IPC_CREAT);char str[10];if(id>=0){printf("\nShared memory with id:%d\n...

Saturday, 19 May 2012

Make bootable pendrive for ubuntu(in windows platform)

It is very easy. First download Universal-USB-Installer. Just fix the locations of pendrive and ISO image. Click create button. That's it. Download Universal- USB-Installer from here                                              ...

Thursday, 17 May 2012

A method to make one click buttons in php

Here is a method to make buttons which will disabled automatically after click. This is useful when you dealing with php scripts.There also other methods for this. Here is only the logic not complete code. <?php mysql_select_db("sample", $p); $z1=$z2=0; $r=mysql_query("SELECT * FROM sampletable"); while($rows=mysql_fetch_array($r)) { $take=$rows['samples2']; if($take=='a1') $z1=1; if($take=='a2') $z2=1; } if($z1==1) echo "<input type='submit' value='a1'  name='opt' disabled >"; else echo "<input type='submit' value='a1'  name='opt'...

Validation of name fields using javascipt

The following code can be used for validating name like fields.(Useful when dealing with html forms) This code uses two built in functions 1)charAt()2) indexOf() charAt()- Returns the character at the specified index in a string. Ex: charAt(5)-->  character at 6th position(Starting with 0) indexOf() - Returns the position of the first occurrence of a specified value in a string and return -1  if  not found. Bellow code has a variable not_needed. You can simply specify the unwanted character inside the double quotes. <script...

Wednesday, 2 May 2012

Sorting of matrix elements-C++ program

#include<iostream> using namespace std; #include<conio.h> int main() {     int a[20][20],n,b[20],m,i,j,k=0,t;     cout<<"Enter the order\n";     cin>>m>>n;     cout<<"Enter the elements\n";     for(i=0;i<m;i++)     {     for(j=0;j<n;j++)     {     cin>>a[i][j];     b[k++]=a[i][j];      }      }      for(i=0;i<(m*n);i++)      {    ...

No third variables and pointers-C++ swapping program

#include<iostream> using namespace std; #include<conio.h> int main() {     int a,b;     cout<<"Enter two number:\t";     cin>>a>>b;     cout<<"\nBefore swapping:\t";     cout<<a<<"\t"<<b;         a=a+b;     b=a-b;     a=a-b;     cout<<"\nAfter swapping:\t";     cout<<"\t"<<a<<"\t"<<b;     getch(); ...

Monday, 30 April 2012

Undo send mails-Eazy trick

                                                                            Yes it is possible to undo our send mails.But with in seconds. Gmail provides...

Wednesday, 7 March 2012

Masm program to check a given year is leap year or not

printmsg macro msg mov ah,09h lea dx,msg int 21h endm printnum macro nu mov dl,nu add dl,30h mov ah,02h int 21h endm calcnum macro regx mov ax,regx mov bl,100 div bl mov dh,ah aam mov bl,al printnum ah printnum bl mov al,dh aam mov bl,al printnum ah printnum bl endm data segment n db,0000 n1 db ,0000 msg1 db 0ah,0dh,"Enter a year$" msg2 db 0ah,0dh,"Leap year$" msg3 db 0ah,0dh,"Not leap year$" msg4 db 0ah,0dh,"$" data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax printmsg msg1 mov ah,01h int 21h sub al,30h mov ah,00 mov...

Monday, 6 February 2012

Masm program to sort n numbers

printmsg macro msg mov ah,09h lea dx,msg int 21h endm printnum macro reg mov dl,reg add dl,30h mov ah,02h int 21h endm calcnum macro regx mov ax,regx mov dh,100 div dh mov n,ah aam mov dh,al printnum ah printnum dh mov al,n aam mov dh,al printnum ah printnum dh endm data segment num db 0 array db 50 dup(0) n db 0 cr equ 0dh msg0 db "Enter a limit(Ex:05)$" msg1 db "Enter the nos(Ex:06)$" msg2 db 0ah,0dh,"After sorting$" msg4 db 0ah,"$" msg5 db 0ah,0dh,"Before sorting$" data ends code segment assume cs:code,ds:data start: mov ax,data mov...

Count number of words in a sentence-Masm program

printmsg macro msg mov ah,09h lea dx,msg int 21h endm printnum macro reg mov dl,reg add dl,30h mov ah,02h int 21h endm data segment str db 40 dup(0) cr equ 0dh lf equ 0ah msg1 db "Enter a string:$" msg4 db 0ah,0dh,"$" msg5 db 0ah,0dh,"No: of words$" data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax lea si,str mov cl,00 printmsg msg1 printmsg msg4 mov ch,'$' mov [si],ch l1: mov ah,01h int 21h cmp al,32 je v1 jmp v2 v1:inc cl jmp v2 v2:cmp al,cr je p3 sub al,30h mov [si],al inc si mov [si],ch jmp l1 p3: mov si,offset...

Friday, 3 February 2012

Masm program-Palindrome checking

printmsg macro msg mov ah,09h lea dx,msg int 21h endm data segment n db 0 array db 40 dup(0) revarray db 40 dup(0) cr equ 0dh msg1 db "Enter a string:$" msg2 db 0ah,0dh,"Palindrome$" msg3 db 0ah,0dh,"Not Palindrome$" msg4 db 0ah,0dh,"$" msg5 db 0ah,0dh,"Reversed string$" data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax lea si,array mov cl,00 printmsg msg1 printmsg msg4 l1: mov ah,01h int 21h cmp al,cr je p2 sub al,30h mov [si],al inc si inc cl jmp l1 p2: mov n,cl mov ch,'$' mov [si],ch printmsg msg4 dec si lea...

Binary to Hexadecimal converter-Masm program

printmsg macro msg mov ah,09h lea dx,msg int 21h endm printnum macro reg mov dl,reg add dl,30h mov ah,02h int 21h endm calcnum macro regx mov ax,regx mov dh,100 div dh mov num,ah aam mov dh,al printnum ah printnum dh mov al,num aam mov dh,al printnum ah printnum dh endm multiply macro num1 mov ax,0001 mov dh,02 mov dl,00 l10: cmp dl,num1 jz l9 mul dh inc dl jmp l10 l9: endm data segment num dw ? num1 db 0 array db 10 dup(0) cr equ 0dh msg1 db "Enter a binary number$" msg2 db 0ah,0dh,"Hex Equivalant$" a db "A$" b db "B$" c db "C$" d db "D$" e...

Binary to Decimal converter- Masm program

printmsg macro msg mov ah,09h lea dx,msg int 21h endm printnum macro reg mov dl,reg add dl,30h mov ah,02h int 21h endm calcnum macro regx mov ax,regx mov dh,100 div dh mov num,ah aam mov dh,al printnum ah printnum dh mov al,num aam mov dh,al printnum ah printnum dh endm multiply macro num1 mov ax,0001 mov dh,02 mov dl,00 l10: cmp dl,num1 jz l9 mul dh inc dl jmp l10 l9: endm data segment num dw ? num1 db 0 array db 10 dup(0) cr equ 0dh msg1 db "Enter a binary number$" msg2 db 0ah,0dh,"Decimal Equivalant$" msg4 db 0ah,"$" data ends code...

Thursday, 2 February 2012

Fibonacci series-Masm program

printmsg macro msg mov ah,09h lea dx,msg int 21h endm printnum macro reg mov dl,reg add dl,30h mov ah,02h int 21h endm calcnum macro regx mov ax,regx mov dh,100 div dh mov num,ah aam mov dh,al printnum ah printnum dh mov al,num aam mov dh,al printnum ah printnum dh endm data segment num dw 0 a dw 0000 b dw ? regx dw ? msg1 db "Enter a non zero limit(Ex: 05)$" msg2 db 0ah,0dh,"Fibnocci series $" msg3 db 0ah,"$" msg5 db 0ah,0dh,"Try again$" data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax printmsg msg1 mov ah,01h int...

Sunday, 29 January 2012

Check a number is Armstrong or not-Masm program

printmsg macro msg mov ah,09h lea dx,msg int 21h endm printnum macro reg mov dl,reg add dl,30h mov ah,02h int 21h endm data segment n dw ? p dw 00 rem dw ? z dw ? cr db,0dh,"$" msg1 db "Enter a number(Ex:0123)$" msg2 db 0ah,0dh,"Armstrong$" msg3 db 0ah,0dh,"Not Armstrong$" msg4 db 0ah,0dh,"$" data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax printmsg msg1 mov ah,01h int 21h mov ah,00 sub al,30h mov dx,1000 mul dx mov n,ax mov ah,01h int 21h mov ah,00 sub al,30h mov dh,100 mul dh add ax,n mov n,ax mov ah,01h int...

Masm program to find prime numbers upto a limit

printmsg macro msg mov ah,09h lea dx,msg int 21h endm printnum macro reg mov dl,reg add dl,30h mov ah,02h int 21h endm calcnum macro regx mov ax,regx mov dh,100 div dh mov num,ah aam mov dh,al printnum ah printnum dh mov al,num aam mov dh,al printnum ah printnum dh endm data segment num dw ? i dw 02 j dw ? n dw ? msg1 db "Enter a limit$" msg2 db 0ah,0dh,"Prime nos:$" msg3 db 0ah,0dh,"$" data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax printmsg msg1 mov dh,02 mov ah,01h int 21h mov ah,00 sub al,30h mov cl,10 mul...

Factorial of a number-Masm program

printmsg macro msg mov ah,09h lea dx,msg int 21h endm printnum macro reg mov dl,reg add dl,30h mov ah,02h int 21h endm calcnum macro regx mov ax,regx mov dh,100 div dh mov num,ah aam mov dh,al printnum ah printnum dh mov al,num aam mov dh,al printnum ah printnum dh endm data segment num dw  ? msg1 db "Enter a number$" msg2 db 0ah,0dh,"Factorial:$" msg3 db 0ah,0dh,"$" data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax printmsg msg1 mov ah,01h int 21h sub al,30h mov ah,00 mov cl,al mov ch,00 mov ax,0001 l1: mul...

Saturday, 28 January 2012

Opera's Turbo - Enable turbo for slow connections

                                                                                                   ...

Friday, 13 January 2012

Removable disk shotcuts in desktop-windows trick

You know in linux when you plug a pendrive ,its shotcut will appear in the desktop. That shotcut will automatically removed when you eject the pendrive.This is also possible in windows through the use of a simple software.                                      ...

Wednesday, 4 January 2012

The Ultimate webcam software-Youcam

Cyberlink's YOUCAM is a super webcam software.Provides many fun  features and effects.Also gives facilities for chatting,video conferencing,work,play etc. Other features 1)Use new Face Login to access online sites like Facebook and eBay. 2)100s of fun features like Augmented Reality, avatars, interactive effects, and gadgets. 3)Record super smooth...

Page 1 of 2712345Next
Twitter Delicious Facebook Digg Stumbleupon Favorites More