Posts

Perl

Perl combines the power of some of most powerful UNIX tools. It is standard on linux and also offered on solaris 8. However, it is free and executable are available for all unix system. 1. Perl Program to input a number and store it in a variable. Make a friend guess the number. Have your program tell your friend whether their guess was high, low, or correct. #! /usr/bin/perl -w print "Enter any number :"; my $ip1 = <STDIN>; print "Guess any number:"; my $ip2 = <STDIN>; if($ip2 > $ip1) {print "ip2 is greater than ip1 ";} elsif($ip2 < $ip1) {print "ip2 is smaller than ip1 ";} else {print "ip2 is equal to ip1 ";} 2. Write a program that stores a number and keeps trying to get user input until the user enters the number correctly. As soon as the correct number is entered, it prints: Correct! #! /usr/bin/perl -w my $x=16; my $y; do{ print "Enter number:"; $y=<STDIN>; }while($x!=$y)

Java Code

Java programming language was originally developed by Sun Microsystems which was initiated by James Gosling and released in 1995 as core component of Sun Microsystems. Software-  IntelliJ IDEA Community Edition 2017.2.6 x64, Java JDK 9. 1. Java Program to print fibonacci series upto nth term. import java.util.Scanner; public class Main { public static void main(String[] args) { int a = 0 , b = 1 , sum = 1 ; Scanner reader = new Scanner(System. in ); // Reading from System.in System. out .println( "Enter a number: " ); int n = reader.nextInt(); reader.close(); for ( int i = 0 ; i < n; i++) { System. out .print( " " +sum); sum = a + b; a = b; b = sum; } } } Output- Enter a number: 6 1 1 2 3 5 8 Process finished with exit code 0 2. Java Program to print ASCII value of Character entered by user. import java.uti

Python Code

Image
Python is a general-purpose interpreted, interactive, object-oriented, and high-level programming language. Python shell can be used in two ways, viz., interactive mode and script mode. Interactive Mode: allows us to interact with OS. When we type Python statement, the interpreter displays the result(s) immediately. Script Mode: In script mode, we type Python program in a file and then use interpreter to execute the content of the file. Working in interactive mode is convenient for beginners and for testing small pieces of code, as one can test them immediately. But for coding of more than few lines, we should always save our code so that it can be modified and reused. Python, in interactive mode, is good enough to learn, experiment or explore, but its only drawback is that we cannot save the statements and have to retype all the statements once again to re-run them.  Software Use-IDLE (Python 3.6.0) Download link of latest version of Python  https://www.python.org/downloads/