print"Enter a number: ";$n=<STDIN>;$s=0;while($n>0){$s=$s+($n%10);$n=$n/10;}print"Sum is $s\n";
Tuesday, November 3, 2015
Perl program to check whether a number is palindrome or not
print"Enter a number: ";$n=<STDIN>;$t=$n;$s=0;while($n>0){$r=$n%10;$s=($s*10)+$r;$n=int($n/10);}if($t==$s){print"Number is palindrome\n";}else{print"Number is not palindrome\n";}
Publisher:
Creative Boyz
- 7:12:00 PM
Perl program to find the Fibonacci series for a given number of terms
print "Enter the limit: ";$n=<STDIN>;$f1=0;$f2=1;print "Fibonacci series:\n";if($n==1){print "0\n";}elsif($n==2){print "0\n1\n";}elsif($n>2){print "0\n1\n";$f3=$f1+$f2;print "$f3\n";for($i=2;$i<$n;$i++){$f1=$f2;$f2=$f3;$f3=$f1+$f2;print "$f3\n";}}
Publisher:
Creative Boyz
- 7:11:00 PM
Perl program to find the factorial of a number ("for" loop)
print "Enter a number: ";$n=<STDIN>;$t=$n;$f=1;for($i=0;$i<$t;$i++){$f=$f*$n;$n=$n-1;}print "Factorial is $f\n";
Publisher:
Creative Boyz
- 7:09:00 PM
Perl program to find the factorial of a number using recursion
print "Enter a number: "; $n=<STDIN>; $t=$n; $i=0; $f=1; while($i<$t) { $f=$f*$n; $n--; $i++; } print "Factorial is
Publisher:
Creative Boyz
- 7:08:00 PM
Java program to implement remote method invocation (RMI)
AddClient.java import java.rmi.*;import java.lang.*;import java.io.*;public class AddClient{public static void main(String args[]){try{String g;int i;String addServerURL="rmi://LocalHost/AddServer";AddServerIntf addServerintf=(AddServerIntf)Naming.lookup(addServerURL);System.out.println("enter a number");BufferedReader s1=new
Publisher:
Creative Boyz
- 6:46:00 PM
Java program to implement sliding window protocol
Sender (slidsender.java) import java.net.*;import java.io.*;import java.rmi.*;public class slidsender{public static void main(String args[]) throws Exception{ServerSocket ser=new ServerSocket(10);Socket s=ser.accept();DataInputStream in=new
Publisher:
Creative Boyz
- 6:42:00 PM
Subscribe to:
Posts (Atom)