Social Icons

Friday 23 August 2013

Generating Random No. In java

import java.util.Random;
class Run
{

public static void main(String args[])
{
 int i;
 Random d = new Random(3);
 Random d1 = new Random(0);
 for(i=0;i<10;i++)
 {
 System.out.println("Print Random value having seed 3  " + d.nextInt(1000));
System.out.println("Print Random value having seed 0 : "+d1.nextInt(1000));
 }
 }

}

output:

Print Random value having seed 3  734
Print Random value having seed 0 : 360
Print Random value having seed 3  660
Print Random value having seed 0 : 948
Print Random value having seed 3  210
Print Random value having seed 0 : 29
Print Random value having seed 3  581
Print Random value having seed 0 : 447
Print Random value having seed 3  128
Print Random value having seed 0 : 515
Print Random value having seed 3  202
Print Random value having seed 0 : 53
Print Random value having seed 3  549
Print Random value having seed 0 : 491
Print Random value having seed 3  564
Print Random value having seed 0 : 761
Print Random value having seed 3  459
Print Random value having seed 0 : 719
Print Random value having seed 3  961
Print Random value having seed 0 : 854

Printing Date in java Program

import java.util.Date;
class New
{

public static void main(String args[])
{

 Date d = new Date();

 System.out.println("Time in millisecond is from 1 jun 1970 " + d.getTime());
System.out.println("Current Date and Time is : "+d.toString());
 }


}

output:

   e:\java_programs>java New
Time in millisecond is  1377282070857
Current Date and Time is : Fri Aug 23 23:51:10 IST 2013

Command line Input Java Program


class New
{
public static void main(String args[])
{

 int a = Integer.parseInt(args[0]);
 int b= Integer.parseInt(args[1]);

 int c=a+b;
 System.out.println("Addition of two no . is  "+c);
}


}


output:

               

e:\java_programs>java New 5 6
Addition of two no . is  11


Java Program Using Scanner class to take Input from user

import java.util.Scanner;
class New
{
public static void main(String args[])
{
 Scanner s= new Scanner(System.in);
 System.out.println("Enter an integer value ");

 int a = s.nextInt();
 System.out.println("Enter 2nd integer");
 int b= s.nextInt();
 int c=a+b;
 System.out.println("Addition of two no. is "+c);
}


}


output:


      e:\java_programs>java New
Enter an integer value
25
Enter 2nd integer
36
Addition of two no. is 61

Full Duplex Mode Communication Using Pipe

#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/ipc.h>
#include<sys/types.h>
int main()
{
int p1[2],p2[2],i;
char buf[20];
pipe(p1);
pipe(p2);
if(fork()==0)
{
printf("\n this is child(the input text is text)\n");
close(p1[1]);
close(p2[0]);
read(p1[0],buf,20);
write(p2[1],"Hello Papa ! I m fine",25);
printf("\n Parent send the message : %s \n",buf);

}
else
{
printf("\n this is parent(the output text is text)\n");
close(p2[1]);
close(p1[0]);
write(p1[1],"how r u beta",20);

read(p2[0],buf,20);
printf("\n child sending message to parent : %s \n",buf);

}
return 0;
}


Output:
             

Using Fork Command getting Process Id Of Child

#include<sys/types.h>
#include<stdio.h>
#include<stdlib.h>
int main()
{
int pid;
pid=fork();
if(pid==0)
{
printf("\n the process id of child is %d",getpid());
printf("\n the parent process id of child  is %d",getppid());
}

else
{
printf("\n the process id of parent is %d",getpid());
printf("\n the parent process id of parent  is %d",getppid());
}

return 0;

}

Thursday 1 August 2013

How to increase bandwidth of your internet

Here's a simple little thing you can do to increase your bandwidth by at least 20%. 

Ok here we go,  

1.) log on as Administrator. 

2.) start - run - type gpedit.msc 

3.) expand "local computer policy" 

4.) then expand "administrative templates" 

5.) then expand "network branch" 

6.) Highlight/double click the "QoS Packet Scheduler" 

7.) on right window double click "limit reservable bandwidth" 

8.) on setting tab check the "enabled" 

9.) change "Bandwidth limit %" to 0 

You're done.It would be a good idea to reboot after this.


Why did we do that? Simple, Windows is silently eating 20% of your bandwidth. I emphasize on the word “silently” - Remember.
 

Sample Text

Sample text

 
Just Programming Cse DriveReputation Management